internal void FreePage(long pageNumber) { if (_disposed != TxState.None) { ThrowObjectDisposed(); } try { UntrackPage(pageNumber); Debug.Assert(pageNumber >= 0); _pageLocator.Reset(pageNumber); // Remove it from the page locator. _freeSpaceHandling.FreePage(this, pageNumber); _freedPages.Add(pageNumber); if (_scratchPagesTable.TryGetValue(pageNumber, out var scratchPage)) { if (_transactionPages.Remove(scratchPage)) { _unusedScratchPages.Add(scratchPage); } _scratchPagesTable.Remove(pageNumber); } DiscardScratchModificationOn(pageNumber); } catch { _disposed |= TxState.Errored; throw; } }
internal void FreePage(TreePage p) { PageFreed?.Invoke(p.PageNumber); if (p.IsOverflow) { var numberOfPages = _llt.DataPager.GetNumberOfOverflowPages(p.OverflowSize); for (int i = 0; i < numberOfPages; i++) { _llt.FreePage(p.PageNumber + i); _pageLocator.Reset(p.PageNumber + i); } State.RecordFreedPage(p, numberOfPages); } else { _llt.FreePage(p.PageNumber); _pageLocator.Reset(p.PageNumber); State.RecordFreedPage(p, 1); } }
internal void FreePage(long pageNumber) { if (_disposed) { throw new ObjectDisposedException("Transaction"); } UntrackPage(pageNumber); Debug.Assert(pageNumber >= 0); _pageLocator.Reset(pageNumber); // Remove it from the page locator. _freeSpaceHandling.FreePage(this, pageNumber); _freedPages.Add(pageNumber); if (_scratchPagesTable.TryGetValue(pageNumber, out var scratchPage)) { if (_transactionPages.Remove(scratchPage)) { _unusedScratchPages.Add(scratchPage); } _scratchPagesTable.Remove(pageNumber); } if (_dirtyPages.Remove(pageNumber) == false && _dirtyOverflowPages.TryGetValue(pageNumber, out long numberOfOverflowPages)) { _dirtyOverflowPages.Remove(pageNumber); if (numberOfOverflowPages > 1) // prevent adding range which length is 0 { _dirtyOverflowPages.Add(pageNumber + 1, numberOfOverflowPages - 1); // change the range of the overflow page } } UntrackDirtyPage(pageNumber); }