org.apache.derby.iapi.sql.conn
Interface StatementContext

All Superinterfaces:
Context
All Known Implementing Classes:
GenericStatementContext

public interface StatementContext
extends Context

StatementContext keeps the context for a statement.


Method Summary
 void addDependency(Dependency dy)
          Track a Dependency within this StatementContext.
 void cancel()
          Indicate that the statement which has allocated this statement context should cancel its execution.
 void clearInUse()
          Mark this context as not in use.
 void clearSavePoint()
          Clear the save point for the current statement.
 Activation getActivation()
          Get activation associated with this statement context, if any.
 short getSQLAllowed()
          Get the setting of the SQL allowed state.
 SQLSessionContext getSQLSessionContext()
          Get the current SQL session context
 java.lang.String getStatementText()
          Return the text of the current statement.
 NoPutResultSet[] getSubqueryTrackingArray()
          Get the subquery tracking array for this query.
 boolean getSystemCode()
          Return true if this statement is system code.
 boolean inTrigger()
          Returns whether we started from within the context of a trigger or not.
 boolean inUse()
          Is this statement context in use or not.
 boolean isAtomic()
          Indicates whether the statement needs to be executed atomically or not, i.e., whether a commit/rollback is permitted by a connection nested in this statement.
 boolean isCancelled()
          Checks if the statement which has allocated this statement context should cancel its execution.
 boolean isForReadOnly()
          Is this statement for a read only, non-updatable ResultSet
 boolean onStack()
          Reports whether this StatementContext is on the context stack.
 void resetSavePoint()
          If this statement context has a savepoint, then it is reset to the current point.
 void setActivation(Activation a)
          Mark this statement context as associated with this activation.
 void setInUse(boolean inTrigger, boolean isAtomic, boolean isForReadOnly, java.lang.String stmtText, ParameterValueSet pvs, long timeoutMillis)
          Mark this context as being in use.
 void setParentRollback()
          Indicate that, in the event of a statement-level exception, this context is NOT the last one that needs to be rolled back--rather, it is nested within some other statement context, and that other context needs to be rolled back, too.
 void setSavePoint()
          Set a save point for the current statement.
 void setSQLAllowed(short allow, boolean force)
          Set the level of SQL allowed in this and subsequent nested statements due to a routine call.
 void setSQLSessionContext(SQLSessionContext ctx)
          Set the current SQL session context
 void setSubqueryResultSet(int subqueryNumber, NoPutResultSet subqueryResultSet, int numSubqueries)
          Set the appropriate entry in the subquery tracking array for the specified subquery.
 void setSystemCode()
          Set to indicate statement is system code.
 void setTopResultSet(ResultSet topResultSet, NoPutResultSet[] subqueryTrackingArray)
          Set the top ResultSet in the ResultSet tree for close down on an error.
 
Methods inherited from interface org.apache.derby.iapi.services.context.Context
cleanupOnError, getContextManager, getIdName, isLastHandler, popMe, pushMe
 

Method Detail

setInUse

void setInUse(boolean inTrigger,
              boolean isAtomic,
              boolean isForReadOnly,
              java.lang.String stmtText,
              ParameterValueSet pvs,
              long timeoutMillis)
Mark this context as being in use.

Parameters:
inTrigger - true if the parent started in the context of a trigger
isAtomic - true if the statement must be executed atomically
isForReadOnly - true if the statement is for producing non-updatable resultset
stmtText - the text of the statement. Needed for any language statement (currently, for any statement that can cause a trigger to fire). Please set this unless you are some funky jdbc setXXX method or something.
pvs - parameter value set, if it has one
timeoutMillis - timeout value for the statement, in milliseconds. Zero means no timeout.

clearInUse

void clearInUse()
Mark this context as not in use. This is important because we always leave the top statement context on the stack, and we don't want to clean it up if a statement level exception happens while the context is not in use.


setSavePoint

void setSavePoint()
                  throws StandardException
Set a save point for the current statement. NOTE: This needs to be off of the StatementContext so that it gets cleared on a statement error.

Throws:
StandardException - Thrown on error

resetSavePoint

void resetSavePoint()
                    throws StandardException
If this statement context has a savepoint, then it is reset to the current point. Otherwise, it is a noop.

Throws:
StandardException - Thrown on error

clearSavePoint

void clearSavePoint()
                    throws StandardException
Clear the save point for the current statement.

Throws:
StandardException - Thrown on error

setTopResultSet

void setTopResultSet(ResultSet topResultSet,
                     NoPutResultSet[] subqueryTrackingArray)
                     throws StandardException
Set the top ResultSet in the ResultSet tree for close down on an error.

Parameters:
topResultSet - The top ResultSet in the ResultSet tree
subqueryTrackingArray - (Sparse) of tops of subquery ResultSet trees
Throws:
StandardException - Thrown on error

setSubqueryResultSet

void setSubqueryResultSet(int subqueryNumber,
                          NoPutResultSet subqueryResultSet,
                          int numSubqueries)
                          throws StandardException
Set the appropriate entry in the subquery tracking array for the specified subquery. Useful for closing down open subqueries on an exception.

Parameters:
subqueryNumber - The subquery # for this subquery
subqueryResultSet - The NoPutResultSet at the top of the subquery
numSubqueries - The total # of subqueries in the entire query
Throws:
StandardException - Thrown on error

getSubqueryTrackingArray

NoPutResultSet[] getSubqueryTrackingArray()
                                          throws StandardException
Get the subquery tracking array for this query. (Useful for runtime statistics.)

Returns:
NoPutResultSet[] The (sparse) array of tops of subquery ResultSet trees
Throws:
StandardException - Thrown on error

addDependency

void addDependency(Dependency dy)
                   throws StandardException
Track a Dependency within this StatementContext. (We need to clear any dependencies added within this context on an error.

Parameters:
dy - The dependency to track.
Throws:
StandardException - Thrown on error

onStack

boolean onStack()
Reports whether this StatementContext is on the context stack.

Returns:
true if this StatementContext is on the context stack. false otherwise.

inTrigger

boolean inTrigger()
Returns whether we started from within the context of a trigger or not.

Returns:
true if we are in a trigger context

isAtomic

boolean isAtomic()
Indicates whether the statement needs to be executed atomically or not, i.e., whether a commit/rollback is permitted by a connection nested in this statement.

Returns:
true if needs to be atomic

inUse

boolean inUse()
Is this statement context in use or not.

Returns:
true if in use

isForReadOnly

boolean isForReadOnly()
Is this statement for a read only, non-updatable ResultSet

Returns:
true if the statement is for creating a read only, non-updatable ResultSet

isCancelled

boolean isCancelled()
Checks if the statement which has allocated this statement context should cancel its execution.

Returns:
true if the statement execution should be cancelled.

cancel

void cancel()
Indicate that the statement which has allocated this statement context should cancel its execution. Usually called as a consequence of Statement.cancel() or a query timeout set with Statement.setQueryTimeout().


getStatementText

java.lang.String getStatementText()
Return the text of the current statement. Note that this may be null. It is currently not set up correctly for ResultSets that aren't single row result sets (e.g SELECT) and setXXXX/getXXXX jdbc methods.

Returns:
the statement text

setSQLAllowed

void setSQLAllowed(short allow,
                   boolean force)
Set the level of SQL allowed in this and subsequent nested statements due to a routine call. Value must be one of RoutineAliasInfo.{MODIFIES_SQL_DATA, READS_SQL_DATA, CONTAINS_SQL, NO_SQL}

Parameters:
force - set to true to override more restrictive setting. Used to reset the permissions after a function call.

getSQLAllowed

short getSQLAllowed()
Get the setting of the SQL allowed state.


setSystemCode

void setSystemCode()
Set to indicate statement is system code. For example a system procedure, view, function etc.


getSystemCode

boolean getSystemCode()
Return true if this statement is system code.


setParentRollback

void setParentRollback()
Indicate that, in the event of a statement-level exception, this context is NOT the last one that needs to be rolled back--rather, it is nested within some other statement context, and that other context needs to be rolled back, too.


setActivation

void setActivation(Activation a)
Mark this statement context as associated with this activation.

Parameters:
a - activation

getActivation

Activation getActivation()
Get activation associated with this statement context, if any. Used to link up stack of activations of calls in nested connections, see GenericPreparedStatement#getActivation.


getSQLSessionContext

SQLSessionContext getSQLSessionContext()
Get the current SQL session context


setSQLSessionContext

void setSQLSessionContext(SQLSessionContext ctx)
Set the current SQL session context

Parameters:
ctx - the SQL session context

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.