public class Session extends Object
Modifier and Type | Class and Description |
---|---|
static class |
Session.Savepoint
Represents a savepoint (a position in a transaction to where one can roll
back to).
|
static class |
Session.TimeoutValue
An object with a timeout.
|
Modifier and Type | Field and Description |
---|---|
static int |
LOG_WRITTEN
This special log position means that the log entry has been written.
|
protected ArrayList<String> |
sessionState |
protected boolean |
sessionStateChanged |
Constructor and Description |
---|
Session(Database database,
User user,
int id) |
Modifier and Type | Method and Description |
---|---|
void |
addLocalTempTable(Table table)
Add a local temporary table to this session.
|
void |
addLocalTempTableConstraint(Constraint constraint)
Add a local temporary constraint to this session.
|
void |
addLocalTempTableIndex(Index index)
Add a local temporary index to this session.
|
void |
addLock(Table table)
Add a lock for the given table.
|
void |
addLogPos(int logId,
int pos)
Called when a log entry for this session is added.
|
void |
addProcedure(Procedure procedure)
Add a procedure to this session.
|
void |
addSavepoint(String name)
Create a savepoint that is linked to the current log position.
|
void |
addTemporaryLob(Value v)
Add a temporary LOB, which is closed when the session commits.
|
void |
addTemporaryResult(ResultInterface result)
Remember the result set and close it as soon as the transaction is
committed (if it needs to be closed).
|
void |
afterWriting()
Called after writing has ended.
|
void |
begin()
Begin a transaction.
|
void |
cancel()
Cancel the current or next command (called when closing a connection).
|
void |
checkCanceled()
Check if the current transaction is canceled by calling
Statement.cancel() or because a session timeout was set and expired.
|
void |
clearViewIndexCache()
Clear the view cache for this session.
|
void |
close()
Roll back pending transactions and close the session.
|
void |
commit(boolean ddl)
Commit the current transaction.
|
boolean |
containsUncommitted()
Whether the session contains any uncommitted changes.
|
JdbcConnection |
createConnection(boolean columnList)
Create an internal connection.
|
Row |
createRow(Value[] data,
int memory)
Create a new row for a table.
|
void |
endStatement()
Mark the statement as completed.
|
Table |
findLocalTempTable(String name)
Get the local temporary table if one exists with that name, or null if
not.
|
Constraint |
findLocalTempTableConstraint(String name)
Get the local temporary constraint if one exists with that name, or
null if not.
|
Index |
findLocalTempTableIndex(String name)
Get the local temporary index if one exists with that name, or null if
not.
|
boolean |
getAllowLiterals() |
boolean |
getAutoCommit()
Check if this session is in auto-commit mode.
|
long |
getCancel()
Get the cancel time.
|
ArrayList<String> |
getClusterServers()
Get the list of the cluster servers for this session.
|
ColumnNamerConfiguration |
getColumnNamerConfiguration() |
Command |
getCurrentCommand() |
long |
getCurrentCommandStart() |
String |
getCurrentSchemaName()
Get current schema.
|
Database |
getDatabase() |
DataHandler |
getDataHandler()
Get the data handler object.
|
int |
getFirstUncommittedLog() |
GeneratedKeys |
getGeneratedKeys() |
int |
getId() |
Value |
getLastIdentity() |
Value |
getLastScopeIdentity() |
Value |
getLastTriggerIdentity() |
HashMap<String,Constraint> |
getLocalTempTableConstraints()
Get the map of constraints for all constraints on local, temporary
tables, if any.
|
HashMap<String,Index> |
getLocalTempTableIndexes() |
ArrayList<Table> |
getLocalTempTables() |
Table[] |
getLocks() |
int |
getLockTimeout() |
int |
getModificationId() |
String |
getNextSystemIdentifier(String sql)
Get the next system generated identifiers.
|
String |
getParsingCreateViewName() |
int |
getPowerOffCount()
Get the number of disk operations before power failure is simulated.
|
Procedure |
getProcedure(String name)
Get the procedure with the given name, or null
if none exists.
|
int |
getQueryTimeout() |
Random |
getRandom() |
String[] |
getSchemaSearchPath() |
long |
getSessionStart() |
long |
getStatementSavepoint() |
SubQueryInfo |
getSubQueryInfo() |
Trace |
getTrace()
Get the trace object
|
TransactionStore.Transaction |
getTransaction()
Get the transaction to use for this session.
|
Value |
getTransactionId() |
long |
getTransactionStart() |
User |
getUser() |
Value |
getVariable(String name)
Get the value of the specified user defined variable.
|
String[] |
getVariableNames()
Get the list of variable names that are set for this session.
|
Map<Object,ViewIndex> |
getViewIndexCache(boolean subQuery)
Get the view cache for this session.
|
Table |
getWaitForLock() |
Thread |
getWaitForLockThread() |
int |
hashCode() |
boolean |
hasPendingTransaction()
Check whether this session has a pending transaction.
|
boolean |
isClosed()
Check if close was called.
|
boolean |
isForceJoinOrder() |
boolean |
isJoinBatchEnabled() |
boolean |
isLazyQueryExecution() |
boolean |
isParsingCreateView() |
boolean |
isPreparingQueryExpression() |
boolean |
isReconnectNeeded(boolean write)
Check if the database changed and therefore reconnecting is required.
|
boolean |
isRedoLogBinaryEnabled() |
boolean |
isRemote()
Check if this session is remote or embedded.
|
boolean |
isSupportsGeneratedKeys()
Returns is this session supports generated keys.
|
boolean |
isUndoLogEnabled() |
void |
log(Table table,
short operation,
Row row)
Add an undo log entry to this session.
|
void |
markTableForAnalyze(Table table)
Mark that the given table needs to be analyzed on commit.
|
int |
nextObjectId()
Get the next object id.
|
void |
optimizeQueryExpression(Query query)
Optimize a query.
|
void |
popSubQueryInfo()
Remove the current subquery info from the stack.
|
Prepared |
prepare(String sql)
Parse and prepare the given SQL statement.
|
Prepared |
prepare(String sql,
boolean rightsChecked,
boolean literalsChecked)
Parse and prepare the given SQL statement.
|
CommandInterface |
prepareCommand(String sql,
int fetchSize)
Parse a command and prepare it for execution.
|
void |
prepareCommit(String transactionName)
Prepare the given transaction.
|
Command |
prepareLocal(String sql)
Parse and prepare the given SQL statement.
|
void |
pushSubQueryInfo(int[] masks,
TableFilter[] filters,
int filter,
SortOrder sortOrder)
Add a subquery info on top of the subquery info stack.
|
void |
readSessionState()
Read the session state if necessary.
|
SessionInterface |
reconnect(boolean write)
Close the connection and open a new connection.
|
protected void |
recreateSessionState()
Re-create the session state using the stored sessionState list.
|
void |
removeAtCommit(Value v)
Remember that the given LOB value must be removed at commit.
|
void |
removeAtCommitStop(Value v)
Do not remove this LOB value at commit any longer.
|
void |
removeLocalTempTable(Table table)
Drop and remove the given local temporary table from this session.
|
void |
removeLocalTempTableIndex(Index index)
Drop and remove the given local temporary index from this session.
|
void |
removeProcedure(String name)
Remove a procedure from this session.
|
void |
rollback()
Fully roll back the current transaction.
|
void |
rollbackTo(Session.Savepoint savepoint,
boolean trimToSize)
Partially roll back the current transaction.
|
void |
rollbackToSavepoint(String name)
Undo all operations back to the log position of the given savepoint.
|
void |
setAllowLiterals(boolean b) |
void |
setAutoCommit(boolean b)
Set the auto-commit mode.
|
void |
setColumnNamerConfiguration(ColumnNamerConfiguration columnNamerConfiguration) |
boolean |
setCommitOrRollbackDisabled(boolean x) |
void |
setConnectionInfo(ConnectionInfo ci) |
void |
setCurrentCommand(Command command,
Object generatedKeysRequest)
Set the current command of this session.
|
void |
setCurrentSchema(Schema schema) |
void |
setCurrentSchemaName(String schemaName)
Set current schema.
|
void |
setForceJoinOrder(boolean forceJoinOrder) |
void |
setJoinBatchEnabled(boolean joinBatchEnabled) |
void |
setLastIdentity(Value last) |
void |
setLastScopeIdentity(Value last) |
void |
setLastTriggerIdentity(Value last) |
void |
setLazyQueryExecution(boolean lazyQueryExecution) |
void |
setLockTimeout(int lockTimeout) |
void |
setParsingCreateView(boolean parsingView,
String viewName)
Stores name of currently parsed view in a stack so it can be determined
during
prepare() . |
void |
setPowerOffCount(int count)
Set the number of disk operations before power failure is simulated.
|
void |
setPreparedTransaction(String transactionName,
boolean commit)
Commit or roll back the given transaction.
|
void |
setQueryTimeout(int queryTimeout) |
void |
setRedoLogBinary(boolean b) |
Session.Savepoint |
setSavepoint()
Create a savepoint to allow rolling back to this state.
|
void |
setSchemaSearchPath(String[] schemas) |
void |
setThrottle(int throttle) |
void |
setUndoLogEnabled(boolean b) |
void |
setVariable(String name,
Value value)
Set the value of the given variable for this session.
|
void |
setWaitForLock(Table waitForLock,
Thread waitForLockThread)
Set the table this session is waiting for, and the thread that is
waiting.
|
void |
startStatementWithinTransaction()
Start a new statement within a transaction.
|
void |
throttle()
Wait for some time if this session is throttled (slowed down).
|
String |
toString() |
void |
unlockReadLocks()
Unlock all read locks.
|
void |
waitIfExclusiveModeEnabled()
Wait if the exclusive mode has been enabled for another session.
|
public static final int LOG_WRITTEN
protected boolean sessionStateChanged
public void setLazyQueryExecution(boolean lazyQueryExecution)
public boolean isLazyQueryExecution()
public void setForceJoinOrder(boolean forceJoinOrder)
public boolean isForceJoinOrder()
public void setJoinBatchEnabled(boolean joinBatchEnabled)
public boolean isJoinBatchEnabled()
public Row createRow(Value[] data, int memory)
data
- the valuesmemory
- whether the row is in memorypublic void pushSubQueryInfo(int[] masks, TableFilter[] filters, int filter, SortOrder sortOrder)
masks
- the maskfilters
- the filtersfilter
- the filter indexsortOrder
- the sort orderpublic void popSubQueryInfo()
public SubQueryInfo getSubQueryInfo()
public void setParsingCreateView(boolean parsingView, String viewName)
prepare()
.parsingView
- true
to store one more name, false
to remove it
from stackviewName
- name of the viewpublic String getParsingCreateViewName()
public boolean isParsingCreateView()
public void optimizeQueryExpression(Query query)
query
- the query to preparepublic boolean isPreparingQueryExpression()
public ArrayList<String> getClusterServers()
SessionInterface
public boolean setCommitOrRollbackDisabled(boolean x)
public void setVariable(String name, Value value)
name
- the name of the variable (may not be null)value
- the new value (may not be null)public Value getVariable(String name)
name
- the variable namepublic String[] getVariableNames()
public Table findLocalTempTable(String name)
name
- the table namepublic void addLocalTempTable(Table table)
table
- the table to addDbException
- if a table with this name already existspublic void removeLocalTempTable(Table table)
table
- the tablepublic Index findLocalTempTableIndex(String name)
name
- the table namepublic void addLocalTempTableIndex(Index index)
index
- the index to addDbException
- if a index with this name already existspublic void removeLocalTempTableIndex(Index index)
index
- the indexpublic Constraint findLocalTempTableConstraint(String name)
name
- the constraint namepublic HashMap<String,Constraint> getLocalTempTableConstraints()
public void addLocalTempTableConstraint(Constraint constraint)
constraint
- the constraint to addDbException
- if a constraint with the same name already existspublic boolean getAutoCommit()
SessionInterface
public User getUser()
public void setAutoCommit(boolean b)
SessionInterface
b
- the new valuepublic int getLockTimeout()
public void setLockTimeout(int lockTimeout)
public CommandInterface prepareCommand(String sql, int fetchSize)
SessionInterface
sql
- the SQL statementfetchSize
- the number of rows to fetch in one steppublic Prepared prepare(String sql)
sql
- the SQL statementpublic Prepared prepare(String sql, boolean rightsChecked, boolean literalsChecked)
sql
- the SQL statementrightsChecked
- true if the rights have already been checkedliteralsChecked
- true if the sql string has already been checked
for literals (only used if ALLOW_LITERALS NONE is set).public Command prepareLocal(String sql)
sql
- the SQL statementpublic Database getDatabase()
public int getPowerOffCount()
SessionInterface
public void setPowerOffCount(int count)
SessionInterface
count
- the number of operationspublic void commit(boolean ddl)
ddl
- if the statement was a data definition statementpublic void rollback()
public void rollbackTo(Session.Savepoint savepoint, boolean trimToSize)
savepoint
- the savepoint to which should be rolled backtrimToSize
- if the list should be trimmedpublic boolean hasPendingTransaction()
SessionInterface
public Session.Savepoint setSavepoint()
public int getId()
public void cancel()
SessionInterface
public void close()
SessionInterface
public void addLock(Table table)
table
- the table that is lockedpublic void log(Table table, short operation, Row row)
table
- the tableoperation
- the operation type (see UndoLogRecord
)row
- the rowpublic void unlockReadLocks()
public Random getRandom()
public Trace getTrace()
SessionInterface
public void setLastIdentity(Value last)
public Value getLastIdentity()
public void setLastScopeIdentity(Value last)
public Value getLastScopeIdentity()
public void setLastTriggerIdentity(Value last)
public Value getLastTriggerIdentity()
public GeneratedKeys getGeneratedKeys()
public void addLogPos(int logId, int pos)
logId
- the transaction log idpos
- the position of the log entry in the transaction logpublic int getFirstUncommittedLog()
public boolean containsUncommitted()
public void addSavepoint(String name)
name
- the savepoint namepublic void rollbackToSavepoint(String name)
name
- the savepoint namepublic void prepareCommit(String transactionName)
transactionName
- the name of the transactionpublic void setPreparedTransaction(String transactionName, boolean commit)
transactionName
- the name of the transactioncommit
- true for commit, false for rollbackpublic boolean isClosed()
SessionInterface
public void setThrottle(int throttle)
public void throttle()
public void setCurrentCommand(Command command, Object generatedKeysRequest)
command
- the commandgeneratedKeysRequest
- false
if generated keys are not needed, true
if
generated keys should be configured automatically, int[]
to specify column indices to return generated keys from, or
String[]
to specify column names to return generated keys
frompublic void checkCanceled()
DbException
- if the transaction is canceledpublic long getCancel()
public Command getCurrentCommand()
public long getCurrentCommandStart()
public boolean getAllowLiterals()
public void setAllowLiterals(boolean b)
public void setCurrentSchema(Schema schema)
public String getCurrentSchemaName()
SessionInterface
public void setCurrentSchemaName(String schemaName)
SessionInterface
schemaName
- the schema namepublic JdbcConnection createConnection(boolean columnList)
columnList
- if the url should be 'jdbc:columnlist:connection'public DataHandler getDataHandler()
SessionInterface
public void removeAtCommit(Value v)
v
- the valuepublic void removeAtCommitStop(Value v)
v
- the valuepublic String getNextSystemIdentifier(String sql)
sql
- the SQL statementpublic void addProcedure(Procedure procedure)
procedure
- the procedure to addpublic void removeProcedure(String name)
name
- the name of the procedure to removepublic Procedure getProcedure(String name)
name
- the procedure namepublic void setSchemaSearchPath(String[] schemas)
public String[] getSchemaSearchPath()
public void setUndoLogEnabled(boolean b)
public void setRedoLogBinary(boolean b)
public boolean isUndoLogEnabled()
public void begin()
public long getSessionStart()
public long getTransactionStart()
public Table[] getLocks()
public void waitIfExclusiveModeEnabled()
public Map<Object,ViewIndex> getViewIndexCache(boolean subQuery)
subQuery
- true to get the subquery cachepublic void addTemporaryResult(ResultInterface result)
result
- the temporary result setpublic void setQueryTimeout(int queryTimeout)
public int getQueryTimeout()
public void setWaitForLock(Table waitForLock, Thread waitForLockThread)
waitForLock
- the tablewaitForLockThread
- the current thread (the one that is waiting)public Table getWaitForLock()
public Thread getWaitForLockThread()
public int getModificationId()
public boolean isReconnectNeeded(boolean write)
SessionInterface
write
- if the next operation may be writingpublic void afterWriting()
SessionInterface
public SessionInterface reconnect(boolean write)
SessionInterface
write
- if the next operation may be writingpublic void setConnectionInfo(ConnectionInfo ci)
public Value getTransactionId()
public int nextObjectId()
public boolean isRedoLogBinaryEnabled()
public TransactionStore.Transaction getTransaction()
public long getStatementSavepoint()
public void startStatementWithinTransaction()
public void endStatement()
public void clearViewIndexCache()
public void addTemporaryLob(Value v)
SessionInterface
v
- the valuepublic boolean isRemote()
SessionInterface
public void markTableForAnalyze(Table table)
table
- the tablepublic ColumnNamerConfiguration getColumnNamerConfiguration()
public void setColumnNamerConfiguration(ColumnNamerConfiguration columnNamerConfiguration)
public boolean isSupportsGeneratedKeys()
SessionInterface
true
if generated keys are supported, false
if only
SCOPE_IDENTITY()
is supportedprotected void recreateSessionState()
public void readSessionState()
Copyright © 2020 JBoss by Red Hat. All rights reserved.