The system implementation of a transaction model that handles isolated operations within a database context.
Inheritance: ITransaction, ICallbackHandler, ITableStateHandler
Example #1
0
        internal TransactionWork(TableSourceComposite composite, Transaction transaction, IEnumerable<TableSource> selectedFromTables, IEnumerable<IMutableTable> touchedTables, TransactionRegistry journal)
        {
            Composite = composite;
            Transaction = transaction;
            SelectedFromTables = selectedFromTables;

            // Get individual journals for updates made to tables in this
            // transaction.
            // The list TableEventRegistry

            ChangedTables = touchedTables.Select(t => t.EventRegistry).Where(tableJournal => tableJournal.EventCount > 0);

            // The list of tables created by this journal.
            CreatedTables = journal.TablesCreated;
            // Ths list of tables dropped by this journal.
            DroppedTables = journal.TablesDropped;
            // The list of tables that constraints were alter by this journal
            ConstraintAlteredTables = journal.TablesConstraintAltered;

            // Get the list of all database objects that were created in the
            // transaction.
            ObjectsCreated = transaction.Registry.ObjectsCreated;
            // Get the list of all database objects that were dropped in the
            // transaction.
            ObjectsDropped = transaction.Registry.ObjectsDropped;

            CommitId = transaction.CommitId;
        }
        internal void Rollback(Transaction transaction, IList<IMutableTable> touchedTables, TransactionRegistry journal)
        {
            // Go through the journal.  Any rows added should be marked as deleted
            // in the respective master table.

            // Get individual journals for updates made to tables in this
            // transaction.
            // The list MasterTableJournal
            var journalList = new List<TableEventRegistry>();
            for (int i = 0; i < touchedTables.Count; ++i) {
                var tableJournal = touchedTables[i].EventRegistry;
                if (tableJournal.EventCount > 0) // Check the journal has entries.
                    journalList.Add(tableJournal);
            }

            var changedTables = journalList.ToArray();

            lock (commitLock) {
                try {
                    // For each change to each table,
                    foreach (var changeJournal in changedTables) {
                        // The table the changes were made to.
                        int tableId = changeJournal.TableId;
                        // Get the master table with this table id.
                        var master = GetTableSource(tableId);
                        // Commit the rollback on the table.
                        master.RollbackTransactionChange(changeJournal);
                    }
                } finally {
                    // Notify the conglomerate that this transaction has closed.
                    CloseTransaction(transaction);
                }
            }
        }
        internal void Commit(Transaction transaction, IList<ITableSource> visibleTables,
						   IEnumerable<ITableSource> selectedFromTables,
						   IEnumerable<IMutableTable> touchedTables, TransactionRegistry journal, Action<TableCommitInfo> commitActions)
        {
            var state = new TransactionWork(this, transaction, selectedFromTables, touchedTables, journal);

            // Exit early if nothing changed (this is a Read-only transaction)
            if (!state.HasChanges) {
                CloseTransaction(state.Transaction);
                return;
            }

            lock (commitLock) {
                var changedTablesList = state.Commit(objectStates, commitActions);

                // Flush the journals up to the minimum commit id for all the tables
                // that this transaction changed.
                long minCommitId = Database.TransactionFactory.OpenTransactions.MinimumCommitId(null);
                foreach (var master in changedTablesList) {
                    master.MergeChanges(minCommitId);
                }
                int nsjsz = objectStates.Count;
                for (int i = nsjsz - 1; i >= 0; --i) {
                    var namespaceJournal = objectStates[i];
                    // Remove if the commit id for the journal is less than the minimum
                    // commit id
                    if (namespaceJournal.CommitId < minCommitId) {
                        objectStates.RemoveAt(i);
                    }
                }

                // Set a check point in the store system.  This means that the
                // persistance state is now stable.
                StoreSystem.SetCheckPoint();
            }
        }
Example #4
0
 public TransactionTableContainer(Transaction transaction, TableInfo[] tableInfos)
 {
     this.transaction = transaction;
     this.tableInfos = tableInfos;
 }
Example #5
0
 public OldAndNewTableContainer(Transaction transaction)
 {
     this.transaction = transaction;
 }
Example #6
0
 public ObjectManagersResolver(Transaction transaction)
 {
     this.transaction = transaction;
 }