Exemple #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 Transaction(ITransactionContext context, Database database, int commitId, IsolationLevel isolation, IEnumerable<TableSource> committedTables, IEnumerable<IIndexSet> indexSets)
        {
            CommitId = commitId;
            Database = database;
            Isolation = isolation;
            Context = context;

            context.RegisterInstance<ITransaction>(this);

            Registry = new TransactionRegistry(this);
            TableManager.AddVisibleTables(committedTables, indexSets);

            AddInternalTables();

            TableState = new OldNewTableState();

            IsClosed = false;

            Database.TransactionFactory.OpenTransactions.AddTransaction(this);

            this.CurrentSchema(database.Context.DefaultSchema());
            this.ReadOnly(database.Context.ReadOnly());
            this.AutoCommit(database.Context.AutoCommit());
            this.IgnoreIdentifiersCase(database.Context.IgnoreIdentifiersCase());
            this.ParameterStyle(QueryParameterStyle.Marker);
        }
        public TransactionContext(IDatabaseContext databaseContext)
            : base(databaseContext)
        {
            VariableManager = new VariableManager(this);
            CursorManager = new CursorManager(this);

            EventRegistry = new TransactionRegistry(this);
        }
Exemple #4
0
        internal Transaction(Database database, int commitId, TransactionIsolation isolation, IEnumerable<TableSource> committedTables, IEnumerable<IIndexSet> indexSets)
        {
            CommitId = commitId;
            Database = database;
            Isolation = isolation;

            InitManagers();

            Registry = new TransactionRegistry(this);
            tableManager.AddVisibleTables(committedTables, indexSets);

            AddInternalTables();

            OldNewTableState = new OldNewTableState();

            IsClosed = false;

            Database.TransactionFactory.OpenTransactions.AddTransaction(this);

            currentSchema = database.DatabaseContext.DefaultSchema();
            readOnly = dbReadOnly = database.DatabaseContext.ReadOnly();
            autoCommit = database.DatabaseContext.AutoCommit();
            ignoreCase = database.DatabaseContext.IgnoreIdentifiersCase();
        }
        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();
            }
        }
Exemple #7
0
        internal TransactionWork(TableSourceComposite composite, Transaction transaction, IEnumerable <ITableSource> 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;
        }