net.sf.farrago.session
Interface FarragoSessionStmtContext

All Superinterfaces:
ClosableAllocation, FarragoAllocation
All Known Implementing Classes:
FarragoDbStmtContext, FarragoDbStmtContextBase

public interface FarragoSessionStmtContext
extends FarragoAllocation

FarragoSessionStmtContext represents a context for executing SQL statements within a particular FarragoSession. Contrast with FarragoJdbcEngineStatement (a JDBC wrapper), FarragoSessionPreparingStmt (which manages the preparation process for a single statement), and FarragoSessionExecutableStmt, (which is shared by all sessions).

TODO: document statement lifecycle

Version:
$Id: //open/dev/farrago/src/net/sf/farrago/session/FarragoSessionStmtContext.java#24 $
Author:
John V. Sichi

Method Summary
 void addChildStmtContext(FarragoSessionStmtContext childStmtContext)
          Adds a child statement context to the list of children context for a statement.
 void cancel()
          Cancels execution.
 void clearParameters()
          Clears any settings for all dynamic parameters.
 void closeResultSet()
          Closes any result set associated with this statement context.
 void daemonize()
          Turns this context into a daemon so that it will be deallocated as soon as its current result set is closed.
 void execute()
          Executes the currently prepared statement.
 CancelFlag getCancelFlag()
          Gets the cancellation flag for this context.
 FarragoSessionExecutingStmtInfo getExecutingStmtInfo()
          Returns an object which contains information about this executing statement.
 RelDataType getPreparedParamType()
           
 RelDataType getPreparedRowType()
           
 int getQueryTimeout()
           
 ResultSet getResultSet()
           
 FarragoSession getSession()
           
 String getSql()
           
 long getStmtCurrentTime()
           
 long getUpdateCount()
          Obtains an update count produced by execute(), clearing this information as a side effect.
 FarragoWarningQueue getWarningQueue()
          Gets the warning queue for this statement.
 boolean isPrepared()
           
 boolean isPreparedDml()
           
 void kill()
          Cancels execution and destroys the statement.
 boolean needToSaveFirstTxnCsn()
           
 void prepare(RelNode plan, SqlKind kind, boolean logical, FarragoSessionPreparingStmt prep)
          Prepares a query or DML statement (not DDL), provided as a query plan.
 void prepare(String sql, boolean isExecDirect)
          Prepares an SQL statement.
 void saveFirstTxnCsn(long csn)
          Saves the commit sequence number associated with the first transaction initiated by a stmt associated with a root context.
 void setDynamicParam(int iParam, Object arg)
          Sets an input parameter.
 void setDynamicParam(int iParam, Object arg, Calendar cal)
          Sets an input parameter.
 void setQueryTimeout(int milliseconds)
           
 void setSaveFirstTxnCsn()
          Indicates that the context needs to retrieve and save the commit sequence number for the very first transaction initiated by a stmt context associated with a root context.
 void unprepare()
          Releases any resources (including result sets) associated with this statement context.
 
Methods inherited from interface org.eigenbase.util.ClosableAllocation
closeAllocation
 

Method Detail

getSession

FarragoSession getSession()
Returns:
the session from which this statement context was created

getExecutingStmtInfo

FarragoSessionExecutingStmtInfo getExecutingStmtInfo()
Returns an object which contains information about this executing statement.

Returns:
FarragoSessionExecutingStmtInfo

isPrepared

boolean isPrepared()
Returns:
whether this context currently has a statement prepared

isPreparedDml

boolean isPreparedDml()
Returns:
whether this context currently has a DML statement prepared

daemonize

void daemonize()
Turns this context into a daemon so that it will be deallocated as soon as its current result set is closed.


prepare

void prepare(String sql,
             boolean isExecDirect)
Prepares an SQL statement.

Parameters:
sql - text of statement to be prepared
isExecDirect - whether the statement is being prepared as part of direct execution

prepare

void prepare(RelNode plan,
             SqlKind kind,
             boolean logical,
             FarragoSessionPreparingStmt prep)
Prepares a query or DML statement (not DDL), provided as a query plan. The system uses this to prepare and execute internal statements. As with prepare(String,boolean), the statement can be executed by execute().

Parameters:
plan - a query plan (ie a relational expression).
kind - SqlKind value that characterized the statement.
logical - true when the query plan is logical (needs to be optimized), false when it is physical (already optimized).
prep - the FarragoSessionPreparingStatement that is managing the query plan.

getPreparedRowType

RelDataType getPreparedRowType()
Returns:
the output row type for the currently prepared statement

getPreparedParamType

RelDataType getPreparedParamType()
Returns:
the input parameter row type for the currently prepared statement

setDynamicParam

void setDynamicParam(int iParam,
                     Object arg)
Sets an input parameter.

Parameters:
iParam - 0-based index of parameter to set
arg - value to set

setDynamicParam

void setDynamicParam(int iParam,
                     Object arg,
                     Calendar cal)
Sets an input parameter.

Parameters:
iParam - 0-based index of parameter to set
arg - value to set

clearParameters

void clearParameters()
Clears any settings for all dynamic parameters.


execute

void execute()
Executes the currently prepared statement.


getResultSet

ResultSet getResultSet()
Returns:
the result set produced by execute(), or null if the statement was not a query

getUpdateCount

long getUpdateCount()
Obtains an update count produced by execute(), clearing this information as a side effect.

Returns:
number of rows affected, or -1 if statement is non-DML or its update count was already returned

closeResultSet

void closeResultSet()
Closes any result set associated with this statement context.


cancel

void cancel()
Cancels execution.


getCancelFlag

CancelFlag getCancelFlag()
Gets the cancellation flag for this context. This is part of the implementation of cancel-checking; callers who actually want to request cancellation should use the cancel() method instead.

Returns:
the cancellation flag for this context

kill

void kill()
Cancels execution and destroys the statement.


unprepare

void unprepare()
Releases any resources (including result sets) associated with this statement context.


getWarningQueue

FarragoWarningQueue getWarningQueue()
Gets the warning queue for this statement.

Returns:
warning queue

setQueryTimeout

void setQueryTimeout(int milliseconds)

getQueryTimeout

int getQueryTimeout()

getSql

String getSql()

getStmtCurrentTime

long getStmtCurrentTime()
Returns:
the current time for this statement

setSaveFirstTxnCsn

void setSaveFirstTxnCsn()
Indicates that the context needs to retrieve and save the commit sequence number for the very first transaction initiated by a stmt context associated with a root context. Can only be called on the root context.


needToSaveFirstTxnCsn

boolean needToSaveFirstTxnCsn()
Returns:
whether the context needs to retrieve and save the commit sequence number for the very first transaction initiated by a stmt context associated with a root context; can only be called on the root context

saveFirstTxnCsn

void saveFirstTxnCsn(long csn)
Saves the commit sequence number associated with the first transaction initiated by a stmt associated with a root context. Can only be called on the root context.

Parameters:
csn - the commit sequence number

addChildStmtContext

void addChildStmtContext(FarragoSessionStmtContext childStmtContext)
Adds a child statement context to the list of children context for a statement. Can only be called on the root context.

Parameters:
childStmtContext -