internal static RC sqlite3BtreeIncrVacuum(Btree p) { var pBt = p.Shared; p.sqlite3BtreeEnter(); Debug.Assert(pBt.InTransaction == TRANS.WRITE && p.InTransaction == TRANS.WRITE); RC rc; if (!pBt.AutoVacuum) { rc = RC.DONE; } else { Btree.invalidateAllOverflowCache(pBt); rc = incrVacuumStep(pBt, 0, pBt.btreePagecount()); if (rc == RC.OK) { rc = Pager.Write(pBt.Page1.DbPage); ConvertEx.Put4(pBt.Page1.Data, 28, pBt.Pages); } } p.sqlite3BtreeLeave(); return(rc); }
// was:sqlite3BtreeClose public static RC Close(ref Btree p) { // Close all cursors opened via this handle. Debug.Assert(MutexEx.Held(p.DB.Mutex)); p.sqlite3BtreeEnter(); var shared = p.Shared; var cursor = shared.Cursors; while (cursor != null) { var lastCursor = cursor; cursor = cursor.Next; if (lastCursor.Tree == p) lastCursor.Close(); } // Rollback any active transaction and free the handle structure. The call to sqlite3BtreeRollback() drops any table-locks held by this handle. p.Rollback(); p.sqlite3BtreeLeave(); // If there are still other outstanding references to the shared-btree structure, return now. The remainder of this procedure cleans up the shared-btree. Debug.Assert(p.WantToLock == 0 && !p.Locked); if (!p.Sharable || shared.removeFromSharingList()) { // The pBt is no longer on the sharing list, so we can access it without having to hold the mutex. // Clean out and delete the BtShared object. Debug.Assert(shared.Cursors == null); shared.Pager.Close(); if (shared.xFreeSchema != null && shared.Schema != null) shared.xFreeSchema(shared.Schema); shared.Schema = null;// sqlite3DbFree(0, pBt->pSchema); //freeTempSpace(pBt); shared = null; //sqlite3_free(ref pBt); } #if !SQLITE_OMIT_SHARED_CACHE Debug.Assert(p.WantToLock == 0); Debug.Assert(p.Locked == false); if (p.Prev != null) p.Prev.Next = p.Next; if (p.Next != null) p.Next.Prev = p.Prev; #endif return RC.OK; }
internal static RC sqlite3BtreeIncrVacuum(Btree p) { var pBt = p.Shared; p.sqlite3BtreeEnter(); Debug.Assert(pBt.InTransaction == TRANS.WRITE && p.InTransaction == TRANS.WRITE); RC rc; if (!pBt.AutoVacuum) rc = RC.DONE; else { Btree.invalidateAllOverflowCache(pBt); rc = incrVacuumStep(pBt, 0, pBt.btreePagecount()); if (rc == RC.OK) { rc = Pager.Write(pBt.Page1.DbPage); ConvertEx.Put4(pBt.Page1.Data, 28, pBt.Pages); } } p.sqlite3BtreeLeave(); return rc; }