Class SimpleTransaction
- Direct Known Subclasses:
Transaction
This object does not implement any transaction control mechanisms such as 'commit' or 'rollback'. This object is most useful for setting up a short-term minimal transaction for modifying or querying some data in the database given on some view.
- Author:
- Tobias Downer
-
Method Summary
Modifier and TypeMethodDescriptionlong
currentUniqueID
(TableName table_name) Returns the current unique id for the given table name.final DebugLogger
Debug()
Returns a DebugLogger object that we use to log debug messages to.protected void
Disposes of all IndexSet objects currently accessed by this Transaction.protected com.mckoi.database.MasterTableDataSource
findVisibleTable
(TableName table_name, boolean ignore_case) Searches through the list of tables visible within this transaction and returns the MasterTableDataSource object with the given name.protected void
flushTableCache
(TableName table_name) Flushes the table cache and purges the cache of the entry for the given table name.getDataTableDef
(TableName table_name) Returns the DataTableDef for the table with the given name that is visible within this transaction.protected DataTableDef
getDynamicDataTableDef
(TableName table_name) Returns the DataTableDef for a dynamic table defined in this transaction.protected MutableTableDataSource
getDynamicTable
(TableName table_name) If this transaction implementation defines dynamic tables (tables whose content is determined by some function), this should return the table here as a MutableTableDataSource object.protected TableName[]
Returns a list of all dynamic table names.protected String
getDynamicTableType
(TableName table_name) Returns a string type describing the type of the dynamic table.final TransactionSystem
Returns the TransactionSystem that this Transaction is part of.Returns a MutableTableDataSource object that represents the table with the given name within this transaction.getTableDataSource
(TableName table_name) Returns a TableDataSource object that represents the table with the given name within this transaction.Returns a list of table names that are visible within this transaction.getTableType
(TableName table_name) Returns the type of the table object with the given name.protected com.mckoi.database.MasterTableDataSource
getVisibleTable
(int n) Returns a MasterTableDataSource object representing table 'n' in the set of tables visible in this transaction.protected int
Returns the number of visible tables being managed by this transaction.protected final ArrayList
Returns a list of all visible tables.protected boolean
isDynamicTable
(TableName table_name) Returns true if the given table name is a dynamically generated table and is not a table that is found in the table list defined in this transaction object.boolean
Returns true if the transaction is read-only, otherwise returns false.long
lastSequenceValue
(TableName name) Returns the sequence value for the given sequence generator that was last returned by a call to 'nextSequenceValue'.long
nextSequenceValue
(TableName name) Requests of the sequence generator the next value from the sequence.long
nextUniqueID
(TableName table_name) Atomically returns a unique id that can be used as a seed for a set of unique identifiers for a table.resolveToTableName
(String current_schema, String name, boolean case_insensitive) Resolves the given string to a table name, throwing an exception if the reference is ambiguous.protected final void
setIndexSetForTable
(com.mckoi.database.MasterTableDataSource table, IndexSet index_set) Sets the IndexSet for the given MasterTableDataSource object in this transaction.void
Sets this transaction as read only.void
setSequenceValue
(TableName name, long value) Sets the sequence value for the given sequence generator.void
setUniqueID
(TableName table_name, long unique_id) Sets the unique id for the given table name.boolean
tableExists
(TableName table_name) Returns true if the database table object with the given name exists within this transaction.tryResolveCase
(TableName table_name) Attempts to resolve the given table name to its correct case assuming the table name represents a case insensitive version of the name.
-
Method Details
-
setReadOnly
public void setReadOnly()Sets this transaction as read only. A read only transaction does not allow for the view to be modified in any way. -
isReadOnly
public boolean isReadOnly()Returns true if the transaction is read-only, otherwise returns false. -
getSystem
Returns the TransactionSystem that this Transaction is part of. -
getVisibleTables
Returns a list of all visible tables. -
Debug
Returns a DebugLogger object that we use to log debug messages to. -
getVisibleTableCount
protected int getVisibleTableCount()Returns the number of visible tables being managed by this transaction. -
getVisibleTable
protected com.mckoi.database.MasterTableDataSource getVisibleTable(int n) Returns a MasterTableDataSource object representing table 'n' in the set of tables visible in this transaction. -
findVisibleTable
protected com.mckoi.database.MasterTableDataSource findVisibleTable(TableName table_name, boolean ignore_case) Searches through the list of tables visible within this transaction and returns the MasterTableDataSource object with the given name. Returns null if no visible table with the given name could be found. -
setIndexSetForTable
protected final void setIndexSetForTable(com.mckoi.database.MasterTableDataSource table, IndexSet index_set) Sets the IndexSet for the given MasterTableDataSource object in this transaction. -
isDynamicTable
Returns true if the given table name is a dynamically generated table and is not a table that is found in the table list defined in this transaction object.It is intended this is implemented by derived classes to handle dynamically generated tables (tables based on some function or from an external data source)
-
getDynamicTable
If this transaction implementation defines dynamic tables (tables whose content is determined by some function), this should return the table here as a MutableTableDataSource object. If the table is not defined an exception is generated.It is intended this is implemented by derived classes to handle dynamically generated tables (tables based on some function or from an external data source)
-
getDynamicDataTableDef
Returns the DataTableDef for a dynamic table defined in this transaction.It is intended this is implemented by derived classes to handle dynamically generated tables (tables based on some function or from an external data source)
-
getDynamicTableType
Returns a string type describing the type of the dynamic table.It is intended this is implemented by derived classes to handle dynamically generated tables (tables based on some function or from an external data source)
-
getDynamicTableList
Returns a list of all dynamic table names. We can assume that the object returned here is static so the content of this list should not be changed.It is intended this is implemented by derived classes to handle dynamically generated tables (tables based on some function or from an external data source)
-
flushTableCache
Flushes the table cache and purges the cache of the entry for the given table name. -
disposeAllIndices
protected void disposeAllIndices()Disposes of all IndexSet objects currently accessed by this Transaction. This includes IndexSet objects on tables that have been dropped by operations on this transaction and are in the 'cleanup_queue' object. Disposing of the IndexSet is a common cleanup practice and would typically be used at the end of a transaction. -
getTableDataSource
Returns a TableDataSource object that represents the table with the given name within this transaction. This table is represented by an immutable interface. -
getTable
Returns a MutableTableDataSource object that represents the table with the given name within this transaction. Any changes made to this table are only made within the context of this transaction. This means if a row is added or removed, it is not made perminant until the transaction is committed.If the table does not exist then an exception is thrown.
-
getDataTableDef
Returns the DataTableDef for the table with the given name that is visible within this transaction.Returns null if table name doesn't refer to a table that exists.
-
getTableList
Returns a list of table names that are visible within this transaction. -
tableExists
Returns true if the database table object with the given name exists within this transaction. -
tryResolveCase
Attempts to resolve the given table name to its correct case assuming the table name represents a case insensitive version of the name. For example, "aPP.CuSTOMer" may resolve to "APP.Customer". If the table name can not resolve to a valid identifier it returns the input table name, therefore the actual presence of the table should always be checked by calling 'tableExists' after this method returns. -
getTableType
Returns the type of the table object with the given name. If the table is a base table, this method returns "TABLE". If it is a virtual table, it returns the type assigned to by the InternalTableInfo interface. -
resolveToTableName
Resolves the given string to a table name, throwing an exception if the reference is ambiguous. This also generates an exception if the table object is not found. -
nextSequenceValue
Requests of the sequence generator the next value from the sequence.NOTE: This does NOT check that the user owning this connection has the correct privs to perform this operation.
-
lastSequenceValue
Returns the sequence value for the given sequence generator that was last returned by a call to 'nextSequenceValue'. If a value was not last returned by a call to 'nextSequenceValue' then a statement exception is generated.NOTE: This does NOT check that the user owning this connection has the correct privs to perform this operation.
-
setSequenceValue
Sets the sequence value for the given sequence generator. If the generator does not exist or it is not possible to set the value for the generator then an exception is generated.NOTE: This does NOT check that the user owning this connection has the correct privs to perform this operation.
-
currentUniqueID
Returns the current unique id for the given table name. Note that this is NOT a view of the ID, it is the actual ID value at this time regardless of transaction. -
nextUniqueID
Atomically returns a unique id that can be used as a seed for a set of unique identifiers for a table. Values returned by this method are guarenteed unique within this table. This is true even across transactions.NOTE: This change can not be rolled back.
-
setUniqueID
Sets the unique id for the given table name. This must only be called under very controlled situations, such as when altering a table or when we need to fix sequence corruption.
-