net.sf.farrago.session
Interface FarragoSession

All Superinterfaces:
ClosableAllocation, FarragoAllocation
All Known Implementing Classes:
FarragoDbSession

public interface FarragoSession
extends FarragoAllocation

FarragoSession represents an internal API to the Farrago database. It is designed to serve as a basis for the implementation of standard API's such as JDBC.

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

Method Summary
 FarragoSessionAnalyzedSql analyzeSql(String sql, RelDataTypeFactory typeFactory, RelDataType paramRowType, boolean optimize)
          Analyzes an SQL expression, and returns information about it.
 void cancel()
          Cancels execution of any statements on this session (but does not kill it or them).
 FarragoSession cloneSession(FarragoSessionVariables inheritedVariables)
          Clones this session.
 void commit()
          Commits current transaction if any.
 void disableSubqueryReduction()
          Disables subquery reduction for the current session.
 void endTransactionIfAuto(boolean commit)
          Ends the current transaction if session is in autocommit mode.
 Collection<RefObject> executeLurqlQuery(String lurql, Map<String,?> argMap)
          Executes a LURQL query against the repository.
 FarragoSessionConnectionSource getConnectionSource()
           
 DatabaseMetaData getDatabaseMetaData()
           
 List<FarragoSessionModelExtension> getModelExtensions()
           
 Pattern getOptRuleDescExclusionFilter()
           
 FarragoSessionPersonality getPersonality()
           
 FarragoPluginClassLoader getPluginClassLoader()
           
 FarragoSessionPrivilegeMap getPrivilegeMap()
           
 FarragoRepos getRepos()
           
 FarragoSessionFactory getSessionFactory()
           
 FarragoSessionIndexMap getSessionIndexMap()
           
 FarragoSessionInfo getSessionInfo()
          Returns a FarragoSessionInfo object which contains information on the runtime state of the session (e.g., active statements).
 Timestamp getSessionLabelCreationTimestamp()
          Retrieves the creation timestamp for the session's label setting, if a label setting is set.
 Long getSessionLabelCsn()
          Retrieves the commit sequence number associated with a session's label, if it's set.
 FarragoSessionVariables getSessionVariables()
           
 FarragoSessionTxnId getTxnId(boolean createIfNeeded)
          Gets the ID of the current transaction on this session, optionally initiating a new transaction if none is currently active.
 FarragoSessionTxnMgr getTxnMgr()
           
 String getUrl()
           
 FarragoWarningQueue getWarningQueue()
          Gets the warning queue for this session.
 boolean isAutoCommit()
           
 boolean isClone()
           
 boolean isClosed()
           
 boolean isLoopback()
          Tests whether this session is a loopback session.
 boolean isReentrantAlterTableAddColumn()
          Tests whether this is a reentrant session executing DML on behalf of ALTER TABLE ADD COLUMN.
 boolean isReentrantAlterTableRebuild()
          Tests whether this is a reentrant session executing DML on behalf of ALTER TABLE REBUILD.
 boolean isTxnInProgress()
           
 void kill()
          Kills this session.
 FarragoSessionPrivilegeChecker newPrivilegeChecker()
          Creates a new privilege checker for a session.
 FarragoSessionSavepoint newSavepoint(String name)
          Creates a new savepoint based on the current session state.
 FarragoSessionStmtContext newStmtContext(FarragoSessionStmtParamDefFactory paramDefFactory)
          Creates a new statement context within this session.
 FarragoSessionStmtContext newStmtContext(FarragoSessionStmtParamDefFactory paramDefFactory, FarragoSessionStmtContext rootStmtContext)
          Creates a new statement context within this session.
 FarragoSessionStmtValidator newStmtValidator()
          Creates a new SQL statement validator.
 void releaseSavepoint(FarragoSessionSavepoint savepoint)
          Releases an existing savepoint.
 void rollback(FarragoSessionSavepoint savepoint)
          Rolls back current transaction if any.
 void setAutoCommit(boolean autoCommit)
          Changes the autocommit mode for this session.
 void setConnectionSource(FarragoSessionConnectionSource source)
          Initializes the connection source associated with this session.
 void setDatabaseMetaData(DatabaseMetaData dbMetaData)
          Initializes the database metadata associated with this session.
 void setLoopback()
          Flags this FarragoSession as being a loopback session.
 void setOptRuleDescExclusionFilter(Pattern exclusionFilter)
          Sets the exclusion filter to use for planners created by this session.
 void setSessionIndexMap(FarragoSessionIndexMap sessionIndexMap)
          Overrides the index map associated with this session
 boolean wasKilled()
           
 
Methods inherited from interface org.eigenbase.util.ClosableAllocation
closeAllocation
 

Method Detail

getSessionFactory

FarragoSessionFactory getSessionFactory()
Returns:
the factory which created this session

getPersonality

FarragoSessionPersonality getPersonality()
Returns:
the current personality for this session

newStmtContext

FarragoSessionStmtContext newStmtContext(FarragoSessionStmtParamDefFactory paramDefFactory)
Creates a new statement context within this session.

Parameters:
paramDefFactory - a factory for FarragoSessionStmtParamDef instances
Returns:
new statement context

newStmtContext

FarragoSessionStmtContext newStmtContext(FarragoSessionStmtParamDefFactory paramDefFactory,
                                         FarragoSessionStmtContext rootStmtContext)
Creates a new statement context within this session.

Parameters:
paramDefFactory - a factory for FarragoSessionStmtParamDef instances
rootStmtContext - the root statement context for an internally prepared statement; for an externally prepared statement, this will be null
Returns:
new statement context

newStmtValidator

FarragoSessionStmtValidator newStmtValidator()
Creates a new SQL statement validator.

Returns:
new validator

newPrivilegeChecker

FarragoSessionPrivilegeChecker newPrivilegeChecker()
Creates a new privilege checker for a session. This checker ensures that the session user has the right privileges on the objects which it requests to operate on.

Because privilege checkers are stateful, one privilege checker should be created for each statement.

Returns:
new privilege checker

getPrivilegeMap

FarragoSessionPrivilegeMap getPrivilegeMap()
Returns:
FarragoSessionPrivilegeMap for this session

getUrl

String getUrl()
Returns:
JDBC URL used to establish this session

getRepos

FarragoRepos getRepos()
Returns:
repos accessed by this session

getPluginClassLoader

FarragoPluginClassLoader getPluginClassLoader()
Returns:
ClassLoader for loading plugins

getModelExtensions

List<FarragoSessionModelExtension> getModelExtensions()
Returns:
list of installed FarragoSessionModelExtension instances

isClone

boolean isClone()
Returns:
whether this session is an internal session cloned from another session

isClosed

boolean isClosed()
Returns:
whether this session has already been closed

wasKilled

boolean wasKilled()
Returns:
whether this session was killed (which implies closed)

kill

void kill()
Kills this session. A killed session is closed, so the implementation of this method should insure that ClosableAllocation.closeAllocation() is called. After this method is called, wasKilled() and isClosed() will return true.


cancel

void cancel()
Cancels execution of any statements on this session (but does not kill it or them).


isTxnInProgress

boolean isTxnInProgress()
Returns:
whether this session currently has a transaction in progress

getTxnId

FarragoSessionTxnId getTxnId(boolean createIfNeeded)
Gets the ID of the current transaction on this session, optionally initiating a new transaction if none is currently active.

Parameters:
createIfNeeded - if true and no transaction is active, create a new one
Returns:
transaction ID, or null if no transaction active and !createIfNeeded

getTxnMgr

FarragoSessionTxnMgr getTxnMgr()
Returns:
transaction manager for this session

isAutoCommit

boolean isAutoCommit()
Returns:
whether this session is in autocommit mode

getSessionVariables

FarragoSessionVariables getSessionVariables()
Returns:
current connection defaults for this session

getDatabaseMetaData

DatabaseMetaData getDatabaseMetaData()
Returns:
JDBC database metadata for this session

getConnectionSource

FarragoSessionConnectionSource getConnectionSource()
Returns:
connection source

getSessionIndexMap

FarragoSessionIndexMap getSessionIndexMap()
Returns:
session index map

setDatabaseMetaData

void setDatabaseMetaData(DatabaseMetaData dbMetaData)
Initializes the database metadata associated with this session.

Parameters:
dbMetaData - metadata to set

setConnectionSource

void setConnectionSource(FarragoSessionConnectionSource source)
Initializes the connection source associated with this session.

Parameters:
source - connection source to set

setSessionIndexMap

void setSessionIndexMap(FarragoSessionIndexMap sessionIndexMap)
Overrides the index map associated with this session

Parameters:
sessionIndexMap - index map to set

cloneSession

FarragoSession cloneSession(FarragoSessionVariables inheritedVariables)
Clones this session. TODO: document what this entails.

Parameters:
inheritedVariables - session variables to use for context in new session, or null to inherit those of session being cloned
Returns:
cloned session.

setAutoCommit

void setAutoCommit(boolean autoCommit)
Changes the autocommit mode for this session.

Parameters:
autoCommit - true to request autocommit; false to request manual commit

commit

void commit()
Commits current transaction if any.


endTransactionIfAuto

void endTransactionIfAuto(boolean commit)
Ends the current transaction if session is in autocommit mode. Normally, an attempt to commit or rollback in autocommit mode will cause an exception; this method is for use by other components which need to notify the session that some event (e.g. cursor close) is triggering an autocommit boundary.

Parameters:
commit - true to commit; false to rollback

rollback

void rollback(FarragoSessionSavepoint savepoint)
Rolls back current transaction if any.

Parameters:
savepoint - savepoint to roll back to, or null to rollback entire transaction

newSavepoint

FarragoSessionSavepoint newSavepoint(String name)
Creates a new savepoint based on the current session state.

Parameters:
name - name to give new savepoint, or null for anonymous savepoint
Returns:
new savepoint

releaseSavepoint

void releaseSavepoint(FarragoSessionSavepoint savepoint)
Releases an existing savepoint.

Parameters:
savepoint - savepoint to release

analyzeSql

FarragoSessionAnalyzedSql analyzeSql(String sql,
                                     RelDataTypeFactory typeFactory,
                                     RelDataType paramRowType,
                                     boolean optimize)
Analyzes an SQL expression, and returns information about it. Used when an expression is not going to be executed directly, but needs to be validated as part of the definition of some containing object such as a view.

Parameters:
sql - text of SQL expression
typeFactory - factory for creating result and param types
paramRowType - if non-null, expression is expected to be a function body with these parameters; if null, expression is expected to be a query
optimize - if true, run optimizer as part of analysis; otherwise, skip optimization, returning less information
Returns:
FarragoSessionAnalyzedSql derived from the query

executeLurqlQuery

Collection<RefObject> executeLurqlQuery(String lurql,
                                        Map<String,?> argMap)
Executes a LURQL query against the repository.

Parameters:
lurql - query string
argMap - from parameter name (String) to argument value (typically String or Set)
Returns:
collection of RefObjects retrieved by query

getSessionInfo

FarragoSessionInfo getSessionInfo()
Returns a FarragoSessionInfo object which contains information on the runtime state of the session (e.g., active statements).

Returns:
FarragoSessionInfo object

setOptRuleDescExclusionFilter

void setOptRuleDescExclusionFilter(Pattern exclusionFilter)
Sets the exclusion filter to use for planners created by this session. See RelOptPlanner.setRuleDescExclusionFilter(java.util.regex.Pattern) for details.

Parameters:
exclusionFilter - pattern to match for exclusion; null to disable filtering

getOptRuleDescExclusionFilter

Pattern getOptRuleDescExclusionFilter()
Returns:
exclusion filter in effect for planners created by this session

getWarningQueue

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

Returns:
warning queue

disableSubqueryReduction

void disableSubqueryReduction()
Disables subquery reduction for the current session.


getSessionLabelCsn

Long getSessionLabelCsn()
Retrieves the commit sequence number associated with a session's label, if it's set.

Returns:
the commit sequence number of a session's label; null if the session does not have a label setting

getSessionLabelCreationTimestamp

Timestamp getSessionLabelCreationTimestamp()
Retrieves the creation timestamp for the session's label setting, if a label setting is set.

Returns:
the creation timestamp; null if the session does not have a label setting

setLoopback

void setLoopback()
Flags this FarragoSession as being a loopback session. Loopback sessions do not block server shutdown.


isLoopback

boolean isLoopback()
Tests whether this session is a loopback session.

Returns:
true if this is a loopback session, false otherwise
See Also:
setLoopback()

isReentrantAlterTableRebuild

boolean isReentrantAlterTableRebuild()
Tests whether this is a reentrant session executing DML on behalf of ALTER TABLE REBUILD.

Returns:
true if this session is doing ALTER TABLE REBUILD, false otherwise

isReentrantAlterTableAddColumn

boolean isReentrantAlterTableAddColumn()
Tests whether this is a reentrant session executing DML on behalf of ALTER TABLE ADD COLUMN.

Returns:
true if this session is doing ALTER TABLE ADD COLUMN, false otherwise