|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eigenbase.util.CompoundClosableAllocation net.sf.farrago.util.FarragoCompoundAllocation net.sf.farrago.db.FarragoDbSession
public class FarragoDbSession
FarragoDbSession implements the FarragoSession
interface as a connection to a FarragoDatabase
instance. It manages
private authorization and transaction context.
Most non-trivial public methods on this class must be synchronized, since closeAllocation may be called from a thread shutting down the database.
Nested Class Summary | |
---|---|
private class |
FarragoDbSession.DdlExecutionVisitor
|
private static class |
FarragoDbSession.SessionLabel
|
private static class |
FarragoDbSession.TxnIdRef
|
Field Summary | |
---|---|
private boolean |
catalogDumpRequested
|
private FarragoSessionConnectionSource |
connectionSource
The connection source for this session. |
private FarragoDatabase |
database
Database accessed by this session |
private DatabaseMetaData |
dbMetaData
|
private FarragoSessionPersonality |
defaultPersonality
Default personality for this session. |
private FennelTxnContext |
fennelTxnContext
Fennel transaction context for this session |
private boolean |
isAutoCommit
|
private boolean |
isClone
Was this session produced by cloning? |
private boolean |
isLoopback
|
static String |
MDR_USER_NAME
|
private int |
nextSavepointId
Generator for savepoint Id's. |
private Pattern |
optRuleDescExclusionFilter
|
private FarragoSessionPersonality |
personality
Current personality for this session. |
private FarragoSessionPrivilegeMap |
privilegeMap
|
private FarragoRepos |
repos
Repos accessed by this session |
private boolean |
reposSessionEnded
|
private List<FarragoDbSavepoint> |
savepointList
List of savepoints established within current transaction which have not been released or rolled back; order is from earliest to latest. |
protected FarragoSessionFactory |
sessionFactory
|
private FarragoSessionIndexMap |
sessionIndexMap
Map of temporary indexes created by this session. |
private FarragoDbSessionInfo |
sessionInfo
|
private FarragoDbSession.SessionLabel |
sessionLabel
|
private FarragoSessionVariables |
sessionVariables
Qualifiers to assume for unqualified object references |
private boolean |
shutdownRequested
|
private boolean |
shutDownRequested
|
private static Logger |
sqlTimingTracer
|
private static Logger |
tracer
|
private Map<String,FarragoObjectCache.Entry> |
txnCodeCache
Private cache of executable code pinned by the current txn. |
private FarragoDbSession.TxnIdRef |
txnIdRef
Reference to current transaction ID, or null if none active. |
private String |
url
URL used to connect this session. |
(package private) FarragoWarningQueue |
warningQueue
Warnings accumulated on this session. |
private boolean |
wasKilled
|
Fields inherited from class org.eigenbase.util.CompoundClosableAllocation |
---|
allocations |
Constructor Summary | |
---|---|
FarragoDbSession(String url,
Properties info,
FarragoSessionFactory sessionFactory)
Creates a new FarragoDbSession object. |
Method Summary | |
---|---|
private void |
accessTargetTable(FarragoDbStmtContextBase stmtContext,
FarragoSessionDdlStmt ddlStmt)
Accesses the target table of a DDL statement for write to prevent concurrent DML on the same table. |
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 |
closeAllocation()
Closes this object. |
void |
commit()
Commits current transaction if any. |
(package private) void |
commitImpl()
|
void |
disableSubqueryReduction()
Disables subquery reduction for the current session. |
void |
endTransactionIfAuto(boolean commit)
Ends the current transaction if session is in autocommit mode. |
private void |
executeDdl(FarragoSessionDdlValidator ddlValidator,
FarragoReposTxnContext reposTxnContext,
FarragoSessionDdlStmt ddlStmt)
|
Collection<RefObject> |
executeLurqlQuery(String lurql,
Map<String,?> argMap)
Executes a LURQL query against the repository. |
private int |
findSavepoint(FarragoDbSavepoint savepoint)
|
private int |
findSavepointByName(String name,
boolean throwIfNotFound)
|
FarragoSessionAnalyzedSql |
getAnalysisBlock(RelDataTypeFactory typeFactory)
|
FarragoSessionConnectionSource |
getConnectionSource()
|
FarragoDatabase |
getDatabase()
|
DatabaseMetaData |
getDatabaseMetaData()
|
FennelTxnContext |
getFennelTxnContext()
Accessor for the fennel Txn Context in this session. |
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()
|
(package private) Map<String,FarragoObjectCache.Entry> |
getTxnCodeCache()
|
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. |
private void |
init(Properties info)
|
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. |
private boolean |
isSessionLabelEnabled()
|
boolean |
isTxnInProgress()
|
void |
kill()
Kills this session. |
private void |
markTableInUse(FarragoDbStmtContextBase stmtContext,
FarragoSessionDdlStmt ddlStmt)
Marks the target table for a DDL statement as in-use. |
FarragoSessionPrivilegeChecker |
newPrivilegeChecker()
Creates a new privilege checker for a session. |
protected FarragoSessionRuntimeParams |
newRuntimeContextParams()
|
FarragoSessionSavepoint |
newSavepoint(String name)
Creates a new savepoint based on the current session state. |
private FarragoSessionSavepoint |
newSavepointImpl(String name)
|
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. |
protected void |
onEndOfTransaction(FarragoSessionTxnEnd eot)
|
protected FarragoSessionExecutableStmt |
prepare(FarragoDbStmtContextBase stmtContext,
String sql,
FarragoAllocationOwner owner,
boolean isExecDirect,
FarragoSessionAnalyzedSql analyzedSql)
|
private FarragoSessionExecutableStmt |
prepareImpl(String sql,
FarragoAllocationOwner owner,
boolean isExecDirect,
FarragoSessionAnalyzedSql analyzedSql,
FarragoDbStmtContextBase stmtContext,
FarragoSessionStmtValidator stmtValidator,
FarragoReposTxnContext reposTxnContext,
boolean[] pRollback)
|
void |
releaseSavepoint(FarragoSessionSavepoint savepoint)
Releases an existing savepoint. |
private void |
releaseSavepoint(int iSavepoint)
|
void |
rollback(FarragoSessionSavepoint savepoint)
Rolls back current transaction if any. |
(package private) void |
rollbackImpl()
|
private void |
rollbackToSavepoint(int iSavepoint)
|
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 |
private void |
setSessionLabel(FemLabel label)
|
void |
setShutdownRequest(boolean val)
Turns on a flag indicating whether a shutdown request has been made. |
boolean |
shutdownRequested()
|
private void |
validateDdl(FarragoSessionDdlValidator ddlValidator,
FarragoDbStmtContextBase stmtContext,
FarragoReposTxnContext reposTxnContext,
FarragoSessionDdlStmt ddlStmt)
|
private int |
validateSavepoint(FarragoSessionSavepoint savepoint)
|
boolean |
wasKilled()
|
Methods inherited from class org.eigenbase.util.CompoundClosableAllocation |
---|
addAllocation, forgetAllocation, hasAllocations |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.eigenbase.util.ClosableAllocationOwner |
---|
addAllocation |
Field Detail |
---|
private static final Logger tracer
private static final Logger sqlTimingTracer
public static final String MDR_USER_NAME
private FarragoSessionPersonality defaultPersonality
private FarragoSessionPersonality personality
private FennelTxnContext fennelTxnContext
private FarragoDbSession.TxnIdRef txnIdRef
private FarragoSessionVariables sessionVariables
private FarragoDatabase database
private FarragoRepos repos
private String url
FarragoWarningQueue warningQueue
private boolean isClone
private boolean isAutoCommit
private boolean shutDownRequested
private boolean catalogDumpRequested
private boolean shutdownRequested
private boolean reposSessionEnded
private boolean wasKilled
private List<FarragoDbSavepoint> savepointList
private int nextSavepointId
private FarragoSessionIndexMap sessionIndexMap
private FarragoSessionConnectionSource connectionSource
private Map<String,FarragoObjectCache.Entry> txnCodeCache
private DatabaseMetaData dbMetaData
protected FarragoSessionFactory sessionFactory
private FarragoSessionPrivilegeMap privilegeMap
private FarragoDbSessionInfo sessionInfo
private Pattern optRuleDescExclusionFilter
private FarragoDbSession.SessionLabel sessionLabel
private boolean isLoopback
Constructor Detail |
---|
public FarragoDbSession(String url, Properties info, FarragoSessionFactory sessionFactory)
url
- URL used to connect (same as JDBC)info
- properties for this sessionsessionFactory
- factory which created this sessionMethod Detail |
---|
private void init(Properties info)
public FarragoSessionFactory getSessionFactory()
getSessionFactory
in interface FarragoSession
public FarragoSessionPersonality getPersonality()
getPersonality
in interface FarragoSession
public void setDatabaseMetaData(DatabaseMetaData dbMetaData)
FarragoSession
setDatabaseMetaData
in interface FarragoSession
dbMetaData
- metadata to setpublic void setConnectionSource(FarragoSessionConnectionSource source)
FarragoSession
setConnectionSource
in interface FarragoSession
source
- connection source to setpublic DatabaseMetaData getDatabaseMetaData()
getDatabaseMetaData
in interface FarragoSession
public FarragoSessionConnectionSource getConnectionSource()
getConnectionSource
in interface FarragoSession
public String getUrl()
getUrl
in interface FarragoSession
public FarragoPluginClassLoader getPluginClassLoader()
getPluginClassLoader
in interface FarragoSession
public List<FarragoSessionModelExtension> getModelExtensions()
getModelExtensions
in interface FarragoSession
FarragoSessionModelExtension
instancespublic FarragoSessionInfo getSessionInfo()
FarragoSession
getSessionInfo
in interface FarragoSession
public FarragoWarningQueue getWarningQueue()
FarragoSession
getWarningQueue
in interface FarragoSession
public FarragoSessionStmtContext newStmtContext(FarragoSessionStmtParamDefFactory paramDefFactory)
FarragoSession
newStmtContext
in interface FarragoSession
paramDefFactory
- a factory for FarragoSessionStmtParamDef instances
public FarragoSessionStmtContext newStmtContext(FarragoSessionStmtParamDefFactory paramDefFactory, FarragoSessionStmtContext rootStmtContext)
FarragoSession
newStmtContext
in interface FarragoSession
paramDefFactory
- a factory for FarragoSessionStmtParamDef instancesrootStmtContext
- the root statement context for an internally
prepared statement; for an externally prepared statement, this will be
null
public FarragoSessionStmtValidator newStmtValidator()
FarragoSession
newStmtValidator
in interface FarragoSession
public FarragoSessionPrivilegeChecker newPrivilegeChecker()
FarragoSession
Because privilege checkers are stateful, one privilege checker should be created for each statement.
newPrivilegeChecker
in interface FarragoSession
public FarragoSessionPrivilegeMap getPrivilegeMap()
getPrivilegeMap
in interface FarragoSession
FarragoSessionPrivilegeMap
for this sessionpublic FarragoSession cloneSession(FarragoSessionVariables inheritedVariables)
FarragoSession
cloneSession
in interface FarragoSession
inheritedVariables
- session variables to use for context in new
session, or null to inherit those of session being cloned
public boolean isClone()
isClone
in interface FarragoSession
public boolean isClosed()
isClosed
in interface FarragoSession
public boolean wasKilled()
wasKilled
in interface FarragoSession
public boolean isTxnInProgress()
isTxnInProgress
in interface FarragoSession
public FarragoSessionTxnId getTxnId(boolean createIfNeeded)
FarragoSession
getTxnId
in interface FarragoSession
createIfNeeded
- if true and no transaction is active, create a new
one
public FarragoSessionTxnMgr getTxnMgr()
getTxnMgr
in interface FarragoSession
public void setAutoCommit(boolean autoCommit)
FarragoSession
setAutoCommit
in interface FarragoSession
autoCommit
- true to request autocommit; false to request manual
commitpublic boolean isAutoCommit()
isAutoCommit
in interface FarragoSession
public FarragoSessionVariables getSessionVariables()
getSessionVariables
in interface FarragoSession
public void endTransactionIfAuto(boolean commit)
FarragoSession
endTransactionIfAuto
in interface FarragoSession
commit
- true to commit; false to rollbackpublic FarragoRepos getRepos()
getRepos
in interface FarragoSession
public void kill()
FarragoSession
ClosableAllocation.closeAllocation()
is called. After
this method is called, FarragoSession.wasKilled()
and FarragoSession.isClosed()
will
return true.
kill
in interface FarragoSession
public void cancel()
FarragoSession
cancel
in interface FarragoSession
public void disableSubqueryReduction()
FarragoSession
disableSubqueryReduction
in interface FarragoSession
public void closeAllocation()
ClosableAllocation
closeAllocation
in interface ClosableAllocation
closeAllocation
in class CompoundClosableAllocation
public void commit()
FarragoSession
commit
in interface FarragoSession
public FarragoSessionSavepoint newSavepoint(String name)
FarragoSession
newSavepoint
in interface FarragoSession
name
- name to give new savepoint, or null for anonymous savepoint
public void releaseSavepoint(FarragoSessionSavepoint savepoint)
FarragoSession
releaseSavepoint
in interface FarragoSession
savepoint
- savepoint to releasepublic FarragoSessionAnalyzedSql analyzeSql(String sql, RelDataTypeFactory typeFactory, RelDataType paramRowType, boolean optimize)
FarragoSession
analyzeSql
in interface FarragoSession
sql
- text of SQL expressiontypeFactory
- factory for creating result and param typesparamRowType
- if non-null, expression is expected to be a function
body with these parameters; if null, expression is expected to be a queryoptimize
- if true, run optimizer as part of analysis; otherwise,
skip optimization, returning less information
private void setSessionLabel(FemLabel label)
public Long getSessionLabelCsn()
FarragoSession
getSessionLabelCsn
in interface FarragoSession
public Timestamp getSessionLabelCreationTimestamp()
FarragoSession
getSessionLabelCreationTimestamp
in interface FarragoSession
private boolean isSessionLabelEnabled()
public FarragoSessionAnalyzedSql getAnalysisBlock(RelDataTypeFactory typeFactory)
public FarragoDatabase getDatabase()
public FarragoSessionIndexMap getSessionIndexMap()
getSessionIndexMap
in interface FarragoSession
public void setSessionIndexMap(FarragoSessionIndexMap sessionIndexMap)
FarragoSession
setSessionIndexMap
in interface FarragoSession
sessionIndexMap
- index map to setMap<String,FarragoObjectCache.Entry> getTxnCodeCache()
public FennelTxnContext getFennelTxnContext()
void commitImpl()
void rollbackImpl()
protected void onEndOfTransaction(FarragoSessionTxnEnd eot)
public void rollback(FarragoSessionSavepoint savepoint)
FarragoSession
rollback
in interface FarragoSession
savepoint
- savepoint to roll back to, or null to rollback entire
transactionpublic Collection<RefObject> executeLurqlQuery(String lurql, Map<String,?> argMap)
FarragoSession
executeLurqlQuery
in interface FarragoSession
lurql
- query stringargMap
- from parameter name (String) to argument value (typically
String or Set)
public void setOptRuleDescExclusionFilter(Pattern exclusionFilter)
FarragoSession
RelOptPlanner.setRuleDescExclusionFilter(java.util.regex.Pattern)
for details.
setOptRuleDescExclusionFilter
in interface FarragoSession
exclusionFilter
- pattern to match for exclusion; null to disable
filteringpublic Pattern getOptRuleDescExclusionFilter()
getOptRuleDescExclusionFilter
in interface FarragoSession
protected FarragoSessionRuntimeParams newRuntimeContextParams()
private FarragoSessionSavepoint newSavepointImpl(String name)
private int validateSavepoint(FarragoSessionSavepoint savepoint)
private int findSavepointByName(String name, boolean throwIfNotFound)
private int findSavepoint(FarragoDbSavepoint savepoint)
private void releaseSavepoint(int iSavepoint)
private void rollbackToSavepoint(int iSavepoint)
protected FarragoSessionExecutableStmt prepare(FarragoDbStmtContextBase stmtContext, String sql, FarragoAllocationOwner owner, boolean isExecDirect, FarragoSessionAnalyzedSql analyzedSql)
private FarragoSessionExecutableStmt prepareImpl(String sql, FarragoAllocationOwner owner, boolean isExecDirect, FarragoSessionAnalyzedSql analyzedSql, FarragoDbStmtContextBase stmtContext, FarragoSessionStmtValidator stmtValidator, FarragoReposTxnContext reposTxnContext, boolean[] pRollback)
private void validateDdl(FarragoSessionDdlValidator ddlValidator, FarragoDbStmtContextBase stmtContext, FarragoReposTxnContext reposTxnContext, FarragoSessionDdlStmt ddlStmt)
private void markTableInUse(FarragoDbStmtContextBase stmtContext, FarragoSessionDdlStmt ddlStmt)
FarragoDbSession.DdlExecutionVisitor
during the execution of some types of long-running
DdlStmt.
stmtContext
- context of the DDL statementddlStmt
- the DDL statementprivate void accessTargetTable(FarragoDbStmtContextBase stmtContext, FarragoSessionDdlStmt ddlStmt)
stmtContext
- context of the DDL statementddlStmt
- the DDL statementprivate void executeDdl(FarragoSessionDdlValidator ddlValidator, FarragoReposTxnContext reposTxnContext, FarragoSessionDdlStmt ddlStmt)
public void setShutdownRequest(boolean val)
val
- whether to set the flag to true or falsepublic boolean shutdownRequested()
public void setLoopback()
FarragoSession
setLoopback
in interface FarragoSession
public boolean isLoopback()
FarragoSession
isLoopback
in interface FarragoSession
FarragoSession.setLoopback()
public boolean isReentrantAlterTableRebuild()
FarragoSession
isReentrantAlterTableRebuild
in interface FarragoSession
public boolean isReentrantAlterTableAddColumn()
FarragoSession
isReentrantAlterTableAddColumn
in interface FarragoSession
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |