|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.farrago.db.FarragoDbStmtContextBase
public abstract class FarragoDbStmtContextBase
FarragoDbStmtContextBase provides a partial implementation of FarragoSessionStmtContext
in terms of FarragoDbSession
.
The basic funtionality provided here may be extended to implement statements in a way specific to extension projects.
See individual methods for assistance in determining when they may be called.
Most non-trivial public methods on this class must be synchronized on the parent session, since closeAllocation may be called from a thread shutting down the database. The exception is cancel, which must NOT be synchronized, since it needs to return immediately. (We synchronize on the parent session to avoid deadlocks from session/stmt vs. stmt/session lock order; see http://issues.eigenbase.org/browse/LDB-150 for an example.)
Field Summary | |
---|---|
protected CancelFlag |
cancelFlag
|
protected List<FarragoSessionStmtContext> |
childrenStmtContexts
The children statement contexts associated with a root statement context. |
protected boolean |
daemon
|
private FarragoDdlLockManager |
ddlLockManager
|
protected FarragoSessionStmtParamDef[] |
dynamicParamDefs
Definitions of dynamic parameters. |
protected Object[] |
dynamicParamValues
Current dynamic parameter bindings. |
protected boolean[] |
dynamicParamValuesSet
Indicates if dynamic parameter is set Used to validate that all dynamic parameters have been set |
private FarragoSessionExecutingStmtInfo |
info
|
protected FarragoSessionStmtParamDefFactory |
paramDefFactory
|
protected FarragoSessionStmtContext |
rootStmtContext
|
protected boolean |
saveFirstCsn
Indicates whether the csn associated with the first txn initiated from a root context or one of its children contexts needs to be saved. |
protected FarragoDbSession |
session
|
protected Long |
snapshotCsn
If non-null, the commit sequence number to be used for all transactions associated with a root context as well as children contexts associated with that root context. |
protected String |
sql
|
private long |
stmtCurrentTime
|
protected static Logger |
tracer
|
Constructor Summary | |
---|---|
protected |
FarragoDbStmtContextBase(FarragoDbSession session,
FarragoSessionStmtParamDefFactory paramDefFactory,
FarragoDdlLockManager ddlLockManager)
Creates a new FarragoDbStmtContextBase object. |
protected |
FarragoDbStmtContextBase(FarragoDbSession session,
FarragoSessionStmtParamDefFactory paramDefFactory,
FarragoDdlLockManager ddlLockManager,
FarragoSessionStmtContext rootStmtContext)
Creates a new FarragoDbStmtContextBase object. |
Method Summary | |
---|---|
protected void |
accessTable(List<String> table,
TableAccessMap.Mode mode)
Acquires locks (or whatever transaction manager wants) on a single table. |
protected void |
accessTables(FarragoSessionExecutableStmt executableStmt)
Acquires locks (or whatever transaction manager wants) on all tables accessed by this statement. |
void |
addChildStmtContext(FarragoSessionStmtContext childStmtContext)
Adds a child statement context to the list of children context for a statement. |
protected void |
checkDynamicParamsSet()
Checks that all dynamic parameters have been set. |
protected void |
clearExecutingStmtInfo()
Clears session's FarragoSessionExecutingStmtInfo . |
void |
clearParameters()
Clears any settings for all dynamic parameters. |
void |
closeAllocation()
Closes this object. |
void |
daemonize()
Turns this context into a daemon so that it will be deallocated as soon as its current result set is closed. |
CancelFlag |
getCancelFlag()
Gets the cancellation flag for this context. |
FarragoSessionExecutingStmtInfo |
getExecutingStmtInfo()
Returns an object which contains information about this executing statement. |
FarragoSession |
getSession()
|
private FarragoDbSessionInfo |
getSessionInfo()
|
String |
getSql()
|
long |
getStmtCurrentTime()
|
protected void |
initDynamicParams(RelDataType dynamicParamRowType)
Initializes the dynamicParamDefs and dynamicParamValues
arrays based on the dynamic param row type, |
protected void |
initExecutingStmtInfo(FarragoSessionExecutableStmt executableStmt)
Initializes the session's FarragoSessionExecutingStmtInfo . |
protected void |
lockObjectInUse(String mofId)
Marks a single object, represented by its mofId, as in-use. |
protected void |
lockObjectsInUse(FarragoSessionExecutableStmt newExecutableStmt)
See FarragoDbSession. |
private void |
lockTables(TableAccessMap accessMap)
Calls the transaction manager to access a set of tables. |
boolean |
needToSaveFirstTxnCsn()
|
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 parameterIndex,
Object x)
Sets an input parameter. |
void |
setDynamicParam(int parameterIndex,
Object x,
Calendar cal)
Sets an input parameter. |
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. |
protected void |
startAutocommitTxn(boolean readOnly)
Starts an auto commit transaction. |
protected void |
traceExecute()
Traces execution. |
void |
unprepare()
Releases any resources (including result sets) associated with this statement context. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface net.sf.farrago.session.FarragoSessionStmtContext |
---|
cancel, closeResultSet, execute, getPreparedParamType, getPreparedRowType, getQueryTimeout, getResultSet, getUpdateCount, getWarningQueue, isPrepared, isPreparedDml, kill, prepare, prepare, setQueryTimeout |
Field Detail |
---|
protected static final Logger tracer
protected final FarragoDbSession session
protected final FarragoSessionStmtParamDefFactory paramDefFactory
protected FarragoSessionStmtParamDef[] dynamicParamDefs
protected Object[] dynamicParamValues
protected boolean[] dynamicParamValuesSet
protected boolean daemon
protected String sql
private FarragoDdlLockManager ddlLockManager
private FarragoSessionExecutingStmtInfo info
private final long stmtCurrentTime
protected final FarragoSessionStmtContext rootStmtContext
protected List<FarragoSessionStmtContext> childrenStmtContexts
protected Long snapshotCsn
protected boolean saveFirstCsn
protected final CancelFlag cancelFlag
Constructor Detail |
---|
protected FarragoDbStmtContextBase(FarragoDbSession session, FarragoSessionStmtParamDefFactory paramDefFactory, FarragoDdlLockManager ddlLockManager)
session
- the session creating this statementparamDefFactory
- dynamic parameter definition factoryddlLockManager
- ddl object lock managerprotected FarragoDbStmtContextBase(FarragoDbSession session, FarragoSessionStmtParamDefFactory paramDefFactory, FarragoDdlLockManager ddlLockManager, FarragoSessionStmtContext rootStmtContext)
session
- the session creating this statementparamDefFactory
- dynamic parameter definition factoryddlLockManager
- ddl object lock managerrootStmtContext
- the root statement context for an internally
prepared statement; for an externally prepared statement, this will be
nullMethod Detail |
---|
public void closeAllocation()
ClosableAllocation
closeAllocation
in interface ClosableAllocation
public FarragoSession getSession()
getSession
in interface FarragoSessionStmtContext
public FarragoSessionExecutingStmtInfo getExecutingStmtInfo()
FarragoSessionStmtContext
getExecutingStmtInfo
in interface FarragoSessionStmtContext
public void daemonize()
FarragoSessionStmtContext
daemonize
in interface FarragoSessionStmtContext
public void unprepare()
FarragoSessionStmtContext
unprepare
in interface FarragoSessionStmtContext
public void setDynamicParam(int parameterIndex, Object x)
FarragoSessionStmtContext
setDynamicParam
in interface FarragoSessionStmtContext
parameterIndex
- 0-based index of parameter to setx
- value to setpublic void setDynamicParam(int parameterIndex, Object x, Calendar cal)
FarragoSessionStmtContext
setDynamicParam
in interface FarragoSessionStmtContext
parameterIndex
- 0-based index of parameter to setx
- value to setpublic void clearParameters()
FarragoSessionStmtContext
clearParameters
in interface FarragoSessionStmtContext
public String getSql()
getSql
in interface FarragoSessionStmtContext
public long getStmtCurrentTime()
getStmtCurrentTime
in interface FarragoSessionStmtContext
public void setSaveFirstTxnCsn()
FarragoSessionStmtContext
setSaveFirstTxnCsn
in interface FarragoSessionStmtContext
public boolean needToSaveFirstTxnCsn()
needToSaveFirstTxnCsn
in interface FarragoSessionStmtContext
public void saveFirstTxnCsn(long csn)
FarragoSessionStmtContext
saveFirstTxnCsn
in interface FarragoSessionStmtContext
csn
- the commit sequence numberpublic void addChildStmtContext(FarragoSessionStmtContext childStmtContext)
FarragoSessionStmtContext
addChildStmtContext
in interface FarragoSessionStmtContext
protected void startAutocommitTxn(boolean readOnly)
Call near the beginning of FarragoSessionStmtContext.execute()
.
readOnly
- true if statement is read only (e.g. not DML)protected void initDynamicParams(RelDataType dynamicParamRowType)
dynamicParamDefs
and dynamicParamValues
arrays based on the dynamic param row type,
Call after statement preparation, when the dynamic param row type is
known, but before FarragoSessionStmtContext.setDynamicParam(int,
Object)
or FarragoSessionStmtContext.clearParameters()
.
dynamicParamRowType
- dynamic param row type (e.g., FarragoSessionExecutableStmt.getDynamicParamRowType()
protected void checkDynamicParamsSet()
protected void accessTables(FarragoSessionExecutableStmt executableStmt)
Call during FarragoSessionStmtContext.execute()
to lock tables
used by your FarragoSessionExecutableStmt
.
executableStmt
- executable statementprotected void accessTable(List<String> table, TableAccessMap.Mode mode)
table
- fully qualified table name, represented as a listmode
- access mode for the tableprivate void lockTables(TableAccessMap accessMap)
accessMap
- map containing the tables being accessed and their
access modesprotected void lockObjectsInUse(FarragoSessionExecutableStmt newExecutableStmt)
Call from FarragoSessionStmtContext.prepare(RelNode, SqlKind,
boolean, FarragoSessionPreparingStmt)
after preparation is complete.
newExecutableStmt
- protected void lockObjectInUse(String mofId)
mofId
- mofId of the object being marked as in-useprotected void initExecutingStmtInfo(FarragoSessionExecutableStmt executableStmt)
FarragoSessionExecutingStmtInfo
.
Call before FarragoSessionExecutableStmt.execute(
FarragoSessionRuntimeContext)
.
executableStmt
- executable statementprotected void clearExecutingStmtInfo()
FarragoSessionExecutingStmtInfo
.
Call on FarragoSessionStmtContext.cancel()
, FarragoSessionStmtContext.closeResultSet()
, or whenever the statement is
known to have stopped executing.
public CancelFlag getCancelFlag()
FarragoSessionStmtContext
FarragoSessionStmtContext.cancel()
method instead.
getCancelFlag
in interface FarragoSessionStmtContext
protected void traceExecute()
Optionally, call from FarragoSessionStmtContext.execute()
.
private FarragoDbSessionInfo getSessionInfo()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |