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

java.lang.Object
  extended byorg.apache.derby.impl.sql.execute.BaseActivation
All Implemented Interfaces:
Activation, CursorActivation, GeneratedByteCode
Direct Known Subclasses:
ConstantActionActivation, CursorActivation

public abstract class BaseActivation
extends java.lang.Object
implements CursorActivation, GeneratedByteCode

BaseActivation provides the fundamental support we expect all activations to have. Doesn't actually implement any of the activation interface, expects the subclasses to do that.


Field Summary
private  int[] autoGeneratedKeysColumnIndexes
           
private  java.lang.String[] autoGeneratedKeysColumnNames
           
private  boolean autoGeneratedKeysResultSetMode
           
private  java.util.Calendar cal
           
private  boolean checkRowCounts
           
protected  boolean closed
           
protected  ContextManager cm
           
private  java.lang.String cursorName
           
private  TableDescriptor ddlTableDescriptor
           
protected  DataValueFactory dvFactory
           
protected  ExecutionContext ec
           
protected  ExecutionFactory exFactory
           
private  boolean forCreateTable
           
private  CursorResultSet forUpdateIndexScan
           
private  GeneratedClass gc
           
private  long indexConglomerateNumber
           
protected  int indexOfSessionTableNamesInSavedObjects
           
private  ScanController indexSC
           
private  boolean inUse
           
protected  LanguageConnectionContext lcc
           
private static long MAX_SQRT
           
private  int maxRows
           
protected  int numSubqueries
           
protected  java.util.Hashtable parentResultSets
           
protected  ExecPreparedStatement preStmt
           
protected  ParameterValueSet pvs
           
protected  CursorResultSet[] raParentResultSets
           
protected  ResultDescription resultDescription
           
protected  ResultSet resultSet
           
private  boolean resultSetHoldability
           
protected  ExecRow[] row
           
private  java.util.HashSet rowCountsCheckedThisExecution
           
protected  ResultSetFactory rsFactory
           
private  boolean scrollable
           
private  boolean singleExecution
           
private  java.sql.ResultSet targetVTI
           
private static int TEN_PERCENT_THRESHOLD
           
private  ConglomerateController updateHeapCC
           
private  java.sql.SQLWarning warnings
           
 
Constructor Summary
protected BaseActivation()
           
 
Method Summary
 void addWarning(java.sql.SQLWarning w)
          Add a warning to the activation
static void allocateQualArray(Qualifier[][] qualifiers, int position, int length)
          Allocate an array of qualifiers and initialize in Qualifier[][]
 boolean checkIfThisActivationHasHoldCursor(java.lang.String tableName)
          Temporary tables can be declared with ON COMMIT DELETE ROWS.
protected  void checkPositionedStatement(java.lang.String cursorName, java.lang.String psName)
           
 void checkStatementValidity()
          Check the validity of the current executing statement.
 void clearCurrentRow(int resultSetNumber)
          Clear the current row for the specified ResultSet.
 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()
          prepared statement use the same activation for multiple execution.
 void clearResultSet()
          Sets the ResultSet to be returned by getResultSet() to null.
 void clearWarnings()
          Clear the activation's warnings.
 void close()
          Closing an activation marks it as unusable.
protected  void closeActivationAction()
          A generated class can create its own closeActivationAction method to invoke special logic when the activation is closed.
 java.lang.Object e0()
           
 java.lang.Object e1()
           
 java.lang.Object e2()
           
 java.lang.Object e3()
           
 java.lang.Object e4()
           
 java.lang.Object e5()
           
 java.lang.Object e6()
           
 java.lang.Object e7()
           
 java.lang.Object e8()
           
 java.lang.Object e9()
           
 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.
protected  java.util.Calendar getCalendar()
          Return a calendar for use by this activation.
protected  DataValueDescriptor getColumnFromRow(int rsNumber, int colId)
           
 ConstantAction getConstantAction()
           
 ContextManager getContextManager()
          Get the Current ContextManager.
 java.sql.Connection getCurrentConnection()
          Used to get a proxy for the current connection.
 java.lang.String getCursorName()
          get the cursor name.
 CursorResultSet getCursorResultSet()
          Used in CurrentOfResultSet to get to the cursor result set for a cursor.
 DataValueFactory getDataValueFactory()
          Used by activations to generate data values.
 NumberDataValue getDB2Length(DataValueDescriptor value, int constantLength, NumberDataValue reUse)
          Compute the DB2 compatible length of a value.
 TableDescriptor getDDLTableDescriptor()
          Get the TableDescriptor for the target of DDL.
 java.sql.ResultSet[][] getDynamicResults()
          Real implementations of this method are provided by a generated class.
(package private)  ExecutionContext getExecutionContext()
          Get the ExecutionContext.
protected abstract  int getExecutionCount()
           
 ExecutionFactory getExecutionFactory()
          Used in activations for generating rows.
 boolean getForCreateTable()
          Get whether or not this activation is for create table.
 CursorResultSet getForUpdateIndexScan()
           
 GeneratedClass getGC()
          Get the GeneratedClass object for this object.
 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 factory associated with this connection
 int getMaxDynamicResults()
          Real implementations of this method are provided by a generated class.
 int getMaxRows()
          Get the maximum # of rows. (# of rows that can be returned by a ResultSet. 0 means no limit.)
 GeneratedMethod getMethod(java.lang.String methodName)
           
 int getNumSubqueries()
          Get the number of subqueries in the entire query.
 ParameterValueSet getParameterValueSet()
          return the parameters.
 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.
 ResultSetFactory getResultSetFactory()
          Used in the execute method of activations for generating the result sets that they concatenate together.
 boolean getResultSetHoldability()
          Return the holdability of this activation.
protected abstract  java.util.Vector getRowCountCheckVector()
           
 RowLocation getRowLocationTemplate(int itemNumber)
          Get the saved RowLocation.
 boolean getScrollable()
           
protected  DataValueDescriptor getSetAutoincrementValue(int columnPosition, long increment)
           
protected abstract  int getStalePlanCheckInterval()
           
 CursorResultSet getTargetResultSet()
          Used in CurrentOfResultSet to get to the target result set for a cursor.
 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 currentRowCount)
          Tell this activation that the given ResultSet was found to have the given number of rows.
 void initFromContext(Context context)
          Initialize the generated class from a context.
 boolean isClosed()
          Find out if the activation 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.
 NoPutResultSet materializeResultSetIfPossible(NoPutResultSet rs)
           
protected static void nullToPrimitiveTest(DataValueDescriptor dvd, java.lang.String primitiveType)
           
static void reinitializeQualifiers(Qualifier[][] qualifiers)
          Reinitialize all Qualifiers in an array of Qualifiers.
 void reset()
          This is a partial implementation of reset.
 void setAutoGeneratedKeysResultsetInfo(int[] columnIndexes, java.lang.String[] columnNames)
          Set the auto-generated keys resultset mode to true for this activation.
static void setColumnPosition(int[] columnPositions, int positionToSet, int column)
          Set a column position in an array of column positions.
 void setCurrentRow(ExecRow currentRow, int resultSetNumber)
          Remember the row for the specified ResultSet.
 void setCursorName(java.lang.String cursorName)
          remember the cursor name
 void setDDLTableDescriptor(TableDescriptor td)
          Save the TableDescriptor for the target of DDL so that it can be passed between the various ConstantActions during execution.
protected abstract  void setExecutionCount(int newValue)
           
 void setForCreateTable()
          Mark the Activation as being for create table.
 void setForUpdateIndexScan(CursorResultSet forUpdateIndexScan)
          beetle 3865: updateable cursor using index.
 void setGC(GeneratedClass gc)
          Set the Generated Class.
 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.
protected  void setParameterValueSet(int paramCount, boolean hasReturnParam)
           
 void setParentResultSet(TemporaryRowHolder rs, java.lang.String resultSetId)
           
static void setQualifier(Qualifier[][] qualifiers, Qualifier qualifier, int position_1, int position_2)
          Set a Qualifier in a 2 dimensional array of Qualifiers.
 void setResultSetHoldability(boolean resultSetHoldability)
          Set current resultset holdability.
protected abstract  void setRowCountCheckVector(java.util.Vector newValue)
           
 void setSingleExecution()
          Set this Activation for a single execution.
protected abstract  void setStalePlanCheckInterval(int newValue)
           
 void setTargetVTI(java.sql.ResultSet targetVTI)
          Save the ResultSet for the target of an update/delete to a VTI.
 void setupActivation(ExecPreparedStatement ps, boolean scrollable)
          Link this activation with its PreparedStatement.
private  void shouldWeCheckRowCounts()
           
 void startExecution()
          The subclass calls this method when it begins an execution.
 void throwIfClosed(java.lang.String op)
          Various activation methods need to disallow their invocation if the activation is closed.
 void throwIfMissingParms()
          Throw an exception if any parameters are uninitialized.
 
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.Activation
execute
 
Methods inherited from interface org.apache.derby.iapi.services.loader.GeneratedByteCode
postConstructor
 

Field Detail

rsFactory

protected ResultSetFactory rsFactory

exFactory

protected ExecutionFactory exFactory

dvFactory

protected DataValueFactory dvFactory

lcc

protected LanguageConnectionContext lcc

cm

protected ContextManager cm

ec

protected ExecutionContext ec

preStmt

protected ExecPreparedStatement preStmt

resultSet

protected ResultSet resultSet

resultDescription

protected ResultDescription resultDescription

closed

protected boolean closed

cursorName

private java.lang.String cursorName

numSubqueries

protected int numSubqueries

singleExecution

private boolean singleExecution

inUse

private boolean inUse

targetVTI

private java.sql.ResultSet targetVTI

warnings

private java.sql.SQLWarning warnings

gc

private GeneratedClass gc

checkRowCounts

private boolean checkRowCounts

rowCountsCheckedThisExecution

private java.util.HashSet rowCountsCheckedThisExecution

MAX_SQRT

private static final long MAX_SQRT

TEN_PERCENT_THRESHOLD

private static final int TEN_PERCENT_THRESHOLD
See Also:
Constant Field Values

updateHeapCC

private ConglomerateController updateHeapCC

indexSC

private ScanController indexSC

indexConglomerateNumber

private long indexConglomerateNumber

ddlTableDescriptor

private TableDescriptor ddlTableDescriptor

maxRows

private int maxRows

forCreateTable

private boolean forCreateTable

scrollable

private boolean scrollable

resultSetHoldability

private boolean resultSetHoldability

forUpdateIndexScan

private CursorResultSet forUpdateIndexScan

autoGeneratedKeysResultSetMode

private boolean autoGeneratedKeysResultSetMode

autoGeneratedKeysColumnIndexes

private int[] autoGeneratedKeysColumnIndexes

autoGeneratedKeysColumnNames

private java.lang.String[] autoGeneratedKeysColumnNames

indexOfSessionTableNamesInSavedObjects

protected int indexOfSessionTableNamesInSavedObjects

row

protected ExecRow[] row

pvs

protected ParameterValueSet pvs

raParentResultSets

protected CursorResultSet[] raParentResultSets

parentResultSets

protected java.util.Hashtable parentResultSets

cal

private java.util.Calendar cal
Constructor Detail

BaseActivation

protected BaseActivation()
Method Detail

initFromContext

public final void initFromContext(Context context)
Description copied from interface: GeneratedByteCode
Initialize the generated class from a context. Called by the class manager just after creating the instance of the new class.

Specified by:
initFromContext in interface GeneratedByteCode

getPreparedStatement

public final ExecPreparedStatement getPreparedStatement()
Description copied from interface: Activation
Get the prepared statement that this activation is for.

Specified by:
getPreparedStatement in interface Activation
Returns:
the prepared statement this activation is for.

getConstantAction

public ConstantAction getConstantAction()
Specified by:
getConstantAction in interface Activation

checkStatementValidity

public final void checkStatementValidity()
                                  throws StandardException
Description copied from interface: Activation
Check the validity of the current executing statement. Needs to be called after a statement has obtained the relevant table locks on the

Specified by:
checkStatementValidity in interface Activation
Throws:
StandardException

setupActivation

public final void setupActivation(ExecPreparedStatement ps,
                                  boolean scrollable)
Link this activation with its PreparedStatement. It can be called with null to break the link with the PreparedStatement.


getResultSet

public ResultSet getResultSet()
Description copied from interface: Activation
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.

Specified by:
getResultSet in interface Activation
Returns:
the current ResultSet of this activation.

clearResultSet

public void clearResultSet()
Description copied from interface: Activation
Sets the ResultSet to be returned by getResultSet() to null.

Specified by:
clearResultSet in interface Activation

getRowLocationTemplate

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

Specified by:
getRowLocationTemplate in interface Activation
Parameters:
itemNumber - The saved item number.
Returns:
A RowLocation template for the conglomerate

getResultDescription

public ResultDescription getResultDescription()
Description copied from interface: Activation
Get the result description for this activation, if it has one.

Specified by:
getResultDescription in interface Activation
Returns:
result description for this activation, if it has one; otherwise, null.

reset

public void reset()
           throws StandardException
This is a partial implementation of reset. Subclasses will want to reset information they are aware of, such as parameters.

All subclasses must call super.reset() and then do their cleanup.

The execute call must set the resultSet field to be the resultSet that it has returned.

Specified by:
reset in interface Activation
Returns:
Nothing
Throws:
StandardException - on error

close

public final void close()
                 throws StandardException
Closing an activation 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 should also remove it from the language connection context.

Specified by:
close in interface Activation
Throws:
StandardException - on error

closeActivationAction

protected void closeActivationAction()
                              throws java.lang.Exception
A generated class can create its own closeActivationAction method to invoke special logic when the activation is closed.

Throws:
java.lang.Exception

isClosed

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

Specified by:
isClosed in interface Activation
Returns:
true if the prepared statement has been closed.

setSingleExecution

public void setSingleExecution()
Set this Activation for a single execution.

Specified by:
setSingleExecution in interface Activation
See Also:
Activation.setSingleExecution()

isSingleExecution

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

Specified by:
isSingleExecution in interface Activation
See Also:
Activation.isSingleExecution()

getNumSubqueries

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

Specified by:
getNumSubqueries in interface Activation
Returns:
int The number of subqueries in the entire query.

isCursorActivation

public boolean isCursorActivation()
Description copied from interface: Activation
Is this Activation for a cursor?

Specified by:
isCursorActivation in interface Activation
Returns:
Whether or not this Activation is for a cursor.
See Also:
Activation.isCursorActivation()

setGC

public final void setGC(GeneratedClass gc)
Description copied from interface: GeneratedByteCode
Set the Generated Class. Call by the class manager just after calling initFromContext.

Specified by:
setGC in interface GeneratedByteCode

getGC

public final GeneratedClass getGC()
Description copied from interface: GeneratedByteCode
Get the GeneratedClass object for this object.

Specified by:
getGC in interface GeneratedByteCode

getMethod

public final GeneratedMethod getMethod(java.lang.String methodName)
                                throws StandardException
Specified by:
getMethod in interface GeneratedByteCode
Throws:
StandardException

e0

public java.lang.Object e0()
                    throws StandardException
Specified by:
e0 in interface GeneratedByteCode
Throws:
StandardException

e1

public java.lang.Object e1()
                    throws StandardException
Specified by:
e1 in interface GeneratedByteCode
Throws:
StandardException

e2

public java.lang.Object e2()
                    throws StandardException
Specified by:
e2 in interface GeneratedByteCode
Throws:
StandardException

e3

public java.lang.Object e3()
                    throws StandardException
Specified by:
e3 in interface GeneratedByteCode
Throws:
StandardException

e4

public java.lang.Object e4()
                    throws StandardException
Specified by:
e4 in interface GeneratedByteCode
Throws:
StandardException

e5

public java.lang.Object e5()
                    throws StandardException
Specified by:
e5 in interface GeneratedByteCode
Throws:
StandardException

e6

public java.lang.Object e6()
                    throws StandardException
Specified by:
e6 in interface GeneratedByteCode
Throws:
StandardException

e7

public java.lang.Object e7()
                    throws StandardException
Specified by:
e7 in interface GeneratedByteCode
Throws:
StandardException

e8

public java.lang.Object e8()
                    throws StandardException
Specified by:
e8 in interface GeneratedByteCode
Throws:
StandardException

e9

public java.lang.Object e9()
                    throws StandardException
Specified by:
e9 in interface GeneratedByteCode
Throws:
StandardException

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.

Specified by:
checkIfThisActivationHasHoldCursor in interface Activation
Returns:
true if this activation has held cursor and if it references the passed temp table name

setCursorName

public void setCursorName(java.lang.String cursorName)
remember the cursor name

Specified by:
setCursorName in interface Activation
Parameters:
cursorName - The cursor name to use.

getCursorName

public java.lang.String getCursorName()
get the cursor name. For something that isn't a cursor, this is used as a string name of the result set for messages from things like the dependency manager.

Activations that do support cursors will override this.

Specified by:
getCursorName in interface Activation
Returns:
The cursor name.

setResultSetHoldability

public void setResultSetHoldability(boolean resultSetHoldability)
Description copied from interface: Activation
Set current resultset holdability.

Specified by:
setResultSetHoldability in interface Activation
Parameters:
resultSetHoldability - The new resultset holdability.
Returns:
Nothing.

getResultSetHoldability

public boolean getResultSetHoldability()
Description copied from interface: Activation
Return the holdability of this activation.

Specified by:
getResultSetHoldability in interface Activation
Returns:
The holdability of this activation.

setAutoGeneratedKeysResultsetInfo

public void setAutoGeneratedKeysResultsetInfo(int[] columnIndexes,
                                              java.lang.String[] columnNames)
Description copied from interface: Activation
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.

Specified by:
setAutoGeneratedKeysResultsetInfo in interface Activation
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.
See Also:
Activation.setAutoGeneratedKeysResultsetInfo(int[], java.lang.String[])

getAutoGeneratedKeysResultsetMode

public boolean getAutoGeneratedKeysResultsetMode()
Description copied from interface: Activation
Returns true if auto-generated keys resultset request was made for this avtivation.

Specified by:
getAutoGeneratedKeysResultsetMode in interface Activation
Returns:
auto-generated keys resultset mode for this activation.
See Also:
Activation.getAutoGeneratedKeysResultsetMode()

getAutoGeneratedKeysColumnIndexes

public int[] getAutoGeneratedKeysColumnIndexes()
Description copied from interface: Activation
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

Specified by:
getAutoGeneratedKeysColumnIndexes in interface Activation
Returns:
column positions array of columns requested.
See Also:
Activation.getAutoGeneratedKeysColumnIndexes()

getAutoGeneratedKeysColumnNames

public java.lang.String[] getAutoGeneratedKeysColumnNames()
Description copied from interface: Activation
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

Specified by:
getAutoGeneratedKeysColumnNames in interface Activation
Returns:
column names array of columns requested.
See Also:
Activation.getAutoGeneratedKeysColumnNames()

getResultSetFactory

public ResultSetFactory getResultSetFactory()
Used in the execute method of activations for generating the result sets that they concatenate together.


getExecutionFactory

public ExecutionFactory getExecutionFactory()
Used in activations for generating rows.

Specified by:
getExecutionFactory in interface Activation
Returns:
ExecutionFactory

getTargetResultSet

public CursorResultSet getTargetResultSet()
Used in CurrentOfResultSet to get to the target result set for a cursor. Overridden by activations generated for updatable cursors. Those activations capture the target result set in a field in their execute() method, and then return the value of that field in their version of this method.

Specified by:
getTargetResultSet in interface CursorActivation
Returns:
null.

getSetAutoincrementValue

protected DataValueDescriptor getSetAutoincrementValue(int columnPosition,
                                                       long increment)
                                                throws StandardException
Throws:
StandardException

getCursorResultSet

public CursorResultSet getCursorResultSet()
Used in CurrentOfResultSet to get to the cursor result set for a cursor. Overridden by activations generated for updatable cursors. Those activations capture the cursor result set in a field in their execute() method, and then return the value of that field in their version of this method.

Specified by:
getCursorResultSet in interface CursorActivation
Returns:
null

throwIfClosed

public void throwIfClosed(java.lang.String op)
                   throws StandardException
Various activation methods need to disallow their invocation if the activation is closed. This lets them check and throw without generating alot of code.

The code to write to generate the call to this is approximately: // jf is a JavaFactory CallableExpression ce = jf.newMethodCall( jf.thisExpression(), BaseActivation.CLASS_NAME, "throwIfClosed", "void", acb.exprArray(jf.newStringLiteral(...some literal here...))); //mb is a MethodBuilder mb.addStatement(jf.newStatement(ce)); The java code to write to call this is: this.throwIfClosed(...some literal here...); In both cases, "...some literal here..." gets replaced with an expression of type String that evaluates to the name of the operation that is being checked, like "execute" or "reset".

Throws:
StandardException - thrown if closed

setColumnPosition

public static void setColumnPosition(int[] columnPositions,
                                     int positionToSet,
                                     int column)
Set a column position in an array of column positions.

Parameters:
columnPositions - The array of column positions
positionToSet - The place to put the column position
column - The column position
Returns:
Nothing

allocateQualArray

public static void allocateQualArray(Qualifier[][] qualifiers,
                                     int position,
                                     int length)
Allocate an array of qualifiers and initialize in Qualifier[][]

Parameters:
qualifiers - The array of Qualifier arrays.
position - The position in the array to set
length - The array length of the qualifier array to allocate.

setQualifier

public static void setQualifier(Qualifier[][] qualifiers,
                                Qualifier qualifier,
                                int position_1,
                                int position_2)
Set a Qualifier in a 2 dimensional array of Qualifiers. Set a single Qualifier into one slot of a 2 dimensional array of Qualifiers. @see Qualifier for detailed description of layout of the 2-d array.

Parameters:
qualifiers - The array of Qualifiers
qualifier - The Qualifier
position_1 - The Nth array index into qualifiers[N][M]

reinitializeQualifiers

public static void reinitializeQualifiers(Qualifier[][] qualifiers)
Reinitialize all Qualifiers in an array of Qualifiers.

Parameters:
qualifiers - The array of Qualifiers

markUnused

public final void markUnused()
Mark the activation as unused.

Specified by:
markUnused in interface Activation

isInUse

public final boolean isInUse()
Is the activation in use?

Specified by:
isInUse in interface Activation
Returns:
true/false

addWarning

public void addWarning(java.sql.SQLWarning w)
Description copied from interface: Activation
Add a warning to the activation

Specified by:
addWarning in interface Activation
See Also:
Activation.addWarning(java.sql.SQLWarning)

getWarnings

public java.sql.SQLWarning getWarnings()
Description copied from interface: Activation
Returns the chained list of warnings. Returns null if there are no warnings.

Specified by:
getWarnings in interface Activation
See Also:
Activation.getWarnings()

clearWarnings

public void clearWarnings()
Description copied from interface: Activation
Clear the activation's warnings.

Specified by:
clearWarnings in interface Activation
See Also:
Activation.clearWarnings()

nullToPrimitiveTest

protected static void nullToPrimitiveTest(DataValueDescriptor dvd,
                                          java.lang.String primitiveType)
                                   throws StandardException
Throws:
StandardException - on error

informOfRowCount

public void informOfRowCount(NoPutResultSet resultSet,
                             long currentRowCount)
                      throws StandardException
Description copied from interface: Activation
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.

Specified by:
informOfRowCount in interface Activation
Throws:
StandardException - Thrown on error
See Also:
Activation.informOfRowCount(org.apache.derby.iapi.sql.execute.NoPutResultSet, long)

startExecution

public void startExecution()
                    throws StandardException
The subclass calls this method when it begins an execution.

Throws:
StandardException - Thrown on error

getHeapConglomerateController

public ConglomerateController getHeapConglomerateController()
Description copied from interface: Activation
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.)

Specified by:
getHeapConglomerateController in interface Activation
Returns:
The ConglomerateController, if available, to use for the update.
See Also:
Activation.getHeapConglomerateController()

setHeapConglomerateController

public void setHeapConglomerateController(ConglomerateController updateHeapCC)
Description copied from interface: Activation
Set the ConglomerateController to be used for an update or delete. (Saves opening the ConglomerateController twice.)

Specified by:
setHeapConglomerateController in interface Activation
Parameters:
updateHeapCC - The ConglomerateController to reuse for the update or delete.
Returns:
Nothing.
See Also:
Activation.setHeapConglomerateController(org.apache.derby.iapi.store.access.ConglomerateController)

clearHeapConglomerateController

public void clearHeapConglomerateController()
Description copied from interface: Activation
Clear the ConglomerateController to be used for an update or delete. (Saves opening the ConglomerateController twice.)

Specified by:
clearHeapConglomerateController in interface Activation
Returns:
Nothing.
See Also:
Activation.clearHeapConglomerateController()

getIndexScanController

public ScanController getIndexScanController()
Description copied from interface: Activation
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.)

Specified by:
getIndexScanController in interface Activation
Returns:
The ScanController, if available, to use for the update.
See Also:
Activation.getIndexScanController()

setIndexScanController

public void setIndexScanController(ScanController indexSC)
Description copied from interface: Activation
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.)

Specified by:
setIndexScanController in interface Activation
Parameters:
indexSC - The ScanController to reuse for the update or delete.
Returns:
Nothing.
See Also:
Activation.setIndexScanController(org.apache.derby.iapi.store.access.ScanController)

getIndexConglomerateNumber

public long getIndexConglomerateNumber()
Description copied from interface: Activation
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.)

Specified by:
getIndexConglomerateNumber in interface Activation
Returns:
The conglomerate number, if available, to use for the update.
See Also:
Activation.getIndexConglomerateNumber()

setIndexConglomerateNumber

public void setIndexConglomerateNumber(long indexConglomerateNumber)
Description copied from interface: Activation
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.)

Specified by:
setIndexConglomerateNumber in interface Activation
Parameters:
indexConglomerateNumber - The conglomerate number of the index to reuse for the update or delete.
Returns:
Nothing.
See Also:
Activation.setIndexConglomerateNumber(long)

clearIndexScanInfo

public void clearIndexScanInfo()
Description copied from interface: Activation
Clear the info for the index to be re-used for update/delete. (ScanController and conglomerate number.)

Specified by:
clearIndexScanInfo in interface Activation
Returns:
Nothing.
See Also:
Activation.clearIndexScanInfo()

setForCreateTable

public void setForCreateTable()
Description copied from interface: Activation
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.)

Specified by:
setForCreateTable in interface Activation
Returns:
Nothing.
See Also:
Activation.setForCreateTable()

getForCreateTable

public boolean getForCreateTable()
Description copied from interface: Activation
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.)

Specified by:
getForCreateTable in interface Activation
Returns:
Whether or not this activation is for create table.
See Also:
Activation.getForCreateTable()

setDDLTableDescriptor

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

Specified by:
setDDLTableDescriptor in interface Activation
Returns:
Nothing.
See Also:
Activation.setDDLTableDescriptor(org.apache.derby.iapi.sql.dictionary.TableDescriptor)

getDDLTableDescriptor

public TableDescriptor getDDLTableDescriptor()
Description copied from interface: Activation
Get the TableDescriptor for the target of DDL.

Specified by:
getDDLTableDescriptor in interface Activation
Returns:
The TableDescriptor for the target of DDL.
See Also:
Activation.getDDLTableDescriptor()

setMaxRows

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

Specified by:
setMaxRows in interface Activation
Parameters:
maxRows - Maximum # of rows. (0 means no limit.)
Returns:
Nothing.
See Also:
Activation.setMaxRows(int)

getMaxRows

public int getMaxRows()
Description copied from interface: Activation
Get the maximum # of rows. (# of rows that can be returned by a ResultSet. 0 means no limit.)

Specified by:
getMaxRows in interface Activation
Returns:
Maximum # of rows. (0 means no limit.)
See Also:
Activation.getMaxRows()

setTargetVTI

public void setTargetVTI(java.sql.ResultSet targetVTI)
Description copied from interface: Activation
Save the ResultSet for the target of an update/delete to a VTI.

Specified by:
setTargetVTI in interface Activation
Returns:
Nothing.

getTargetVTI

public java.sql.ResultSet getTargetVTI()
Description copied from interface: Activation
Get the ResultSet for the target of an update/delete to a VTI.

Specified by:
getTargetVTI in interface Activation
Returns:
The ResultSet for the target of an update/delete to a VTI.

shouldWeCheckRowCounts

private void shouldWeCheckRowCounts()
                             throws StandardException
Throws:
StandardException

getExecutionCount

protected abstract int getExecutionCount()

setExecutionCount

protected abstract void setExecutionCount(int newValue)

getRowCountCheckVector

protected abstract java.util.Vector getRowCountCheckVector()

setRowCountCheckVector

protected abstract void setRowCountCheckVector(java.util.Vector newValue)

getStalePlanCheckInterval

protected abstract int getStalePlanCheckInterval()

setStalePlanCheckInterval

protected abstract void setStalePlanCheckInterval(int newValue)

getScrollable

public final boolean getScrollable()

setParameterValueSet

protected final void setParameterValueSet(int paramCount,
                                          boolean hasReturnParam)

getParameterValueSet

public ParameterValueSet getParameterValueSet()
return the parameters.

Specified by:
getParameterValueSet in interface Activation
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
Description copied from interface: Activation
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.

Specified by:
setParameters in interface Activation
Parameters:
parameterValues - The values of the parameters.
Returns:
Nothing
Throws:
StandardException

throwIfMissingParms

public void throwIfMissingParms()
                         throws StandardException
Throw an exception if any parameters are uninitialized.

Returns:
Nothing
Throws:
StandardException - Thrown if any parameters are unitialized

setCurrentRow

public void setCurrentRow(ExecRow currentRow,
                          int resultSetNumber)
Remember the row for the specified ResultSet.

Specified by:
setCurrentRow in interface Activation
Parameters:
currentRow - The row to be operated upon.
resultSetNumber - The resultSetNumber for the current ResultSet
Returns:
Nothing

clearCurrentRow

public void clearCurrentRow(int resultSetNumber)
Clear the current row for the specified ResultSet.

Specified by:
clearCurrentRow in interface Activation
Parameters:
resultSetNumber - The resultSetNumber for the current ResultSet
Returns:
Nothing

getColumnFromRow

protected final DataValueDescriptor getColumnFromRow(int rsNumber,
                                                     int colId)
                                              throws StandardException
Throws:
StandardException

checkPositionedStatement

protected void checkPositionedStatement(java.lang.String cursorName,
                                        java.lang.String psName)
                                 throws StandardException
Throws:
StandardException

materializeResultSetIfPossible

public NoPutResultSet materializeResultSetIfPossible(NoPutResultSet rs)
                                              throws StandardException
Throws:
StandardException

setParentResultSet

public void setParentResultSet(TemporaryRowHolder rs,
                               java.lang.String resultSetId)
Specified by:
setParentResultSet in interface Activation

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.

Specified by:
getParentResultSet in interface Activation

getParentResultSets

public java.util.Hashtable getParentResultSets()
Specified by:
getParentResultSets in interface Activation

clearParentResultSets

public void clearParentResultSets()
prepared statement use the same activation for multiple execution. For each excution we create new set of temporary resultsets, we should clear this hash table. otherwise we will refer to the released resources.

Specified by:
clearParentResultSets in interface Activation

setForUpdateIndexScan

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

Specified by:
setForUpdateIndexScan in interface Activation

getForUpdateIndexScan

public CursorResultSet getForUpdateIndexScan()
Specified by:
getForUpdateIndexScan in interface Activation

getCalendar

protected java.util.Calendar getCalendar()
Return a calendar for use by this activation. Calendar objects are not thread safe, the one returned is purely for use by this activation and it is assumed that is it single threded through the single active thread in a connection model.


getLanguageConnectionContext

public final LanguageConnectionContext getLanguageConnectionContext()
Get the language connection factory associated with this connection

Specified by:
getLanguageConnectionContext in interface Activation

getTransactionController

public final TransactionController getTransactionController()
Description copied from interface: Activation
Get the Execution TransactionController associated with this activation/lcc.

Specified by:
getTransactionController in interface Activation

getExecutionContext

ExecutionContext getExecutionContext()
Get the ExecutionContext.


getContextManager

public ContextManager getContextManager()
Get the Current ContextManager.

Returns:
Current ContextManager

getDataValueFactory

public DataValueFactory getDataValueFactory()
Used by activations to generate data values. Most DML statements will use this method. Possibly some DDL statements will, as well.

Specified by:
getDataValueFactory in interface Activation
Returns:
DataValueFactory

getCurrentConnection

public java.sql.Connection getCurrentConnection()
                                         throws java.sql.SQLException
Used to get a proxy for the current connection.

Throws:
java.sql.SQLException - Thrown on failure to get connection

getDynamicResults

public java.sql.ResultSet[][] getDynamicResults()
Real implementations of this method are provided by a generated class.

Specified by:
getDynamicResults in interface Activation
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()
Real implementations of this method are provided by a generated class.

Specified by:
getMaxDynamicResults in interface Activation

getDB2Length

public NumberDataValue getDB2Length(DataValueDescriptor value,
                                    int constantLength,
                                    NumberDataValue reUse)
                             throws StandardException
Compute the DB2 compatible length of a value.

Parameters:
value -
constantLength - The length, if it is a constant modulo null/not null. -1 if the length is not constant
reUse - If non-null then re-use this as a container for the length
Returns:
the DB2 compatible length, set to null if value is null.
Throws:
StandardException


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