// was:sqlite3PagerSavepoint public RC Savepoint(SAVEPOINT op, int iSavepoint) { var rc = this.errCode; Debug.Assert(op == SAVEPOINT.RELEASE || op == SAVEPOINT.ROLLBACK); Debug.Assert(iSavepoint >= 0 || op == SAVEPOINT.ROLLBACK); if (rc == RC.OK && iSavepoint < this.nSavepoint) { // Figure out how many savepoints will still be active after this operation. Store this value in nNew. Then free resources associated // with any savepoints that are destroyed by this operation. var nNew = iSavepoint + ((op == SAVEPOINT.RELEASE) ? 0 : 1); // Number of remaining savepoints after this op. for (var ii = nNew; ii < this.nSavepoint; ii++) { BitArray.Destroy(ref this.aSavepoint[ii].pInSavepoint); } this.nSavepoint = nNew; // If this is a release of the outermost savepoint, truncate the sub-journal to zero bytes in size. if (op == SAVEPOINT.RELEASE) { if (nNew == 0 && this.sjfd.IsOpen) { // Only truncate if it is an in-memory sub-journal. if (this.sjfd is MemJournalFile) { rc = this.sjfd.Truncate(0); Debug.Assert(rc == RC.OK); } this.nSubRec = 0; } // Else this is a rollback operation, playback the specified savepoint. If this is a temp-file, it is possible that the journal file has // not yet been opened. In this case there have been no changes to the database file, so the playback operation can be skipped. else if (pagerUseWal() || this.jfd.IsOpen) { var pSavepoint = (nNew == 0 ? (PagerSavepoint)null : this.aSavepoint[nNew - 1]); rc = pagerPlaybackSavepoint(pSavepoint); Debug.Assert(rc != RC.DONE); } } } return(rc); }
// was:sqlite3PagerSavepoint public RC Savepoint(SAVEPOINT op, int iSavepoint) { var rc = this.errCode; Debug.Assert(op == SAVEPOINT.RELEASE || op == SAVEPOINT.ROLLBACK); Debug.Assert(iSavepoint >= 0 || op == SAVEPOINT.ROLLBACK); if (rc == RC.OK && iSavepoint < this.nSavepoint) { // Figure out how many savepoints will still be active after this operation. Store this value in nNew. Then free resources associated // with any savepoints that are destroyed by this operation. var nNew = iSavepoint + ((op == SAVEPOINT.RELEASE) ? 0 : 1); // Number of remaining savepoints after this op. for (var ii = nNew; ii < this.nSavepoint; ii++) BitArray.Destroy(ref this.aSavepoint[ii].pInSavepoint); this.nSavepoint = nNew; // If this is a release of the outermost savepoint, truncate the sub-journal to zero bytes in size. if (op == SAVEPOINT.RELEASE) if (nNew == 0 && this.sjfd.IsOpen) { // Only truncate if it is an in-memory sub-journal. if (this.sjfd is MemJournalFile) { rc = this.sjfd.Truncate(0); Debug.Assert(rc == RC.OK); } this.nSubRec = 0; } // Else this is a rollback operation, playback the specified savepoint. If this is a temp-file, it is possible that the journal file has // not yet been opened. In this case there have been no changes to the database file, so the playback operation can be skipped. else if (pagerUseWal() || this.jfd.IsOpen) { var pSavepoint = (nNew == 0 ? (PagerSavepoint)null : this.aSavepoint[nNew - 1]); rc = pagerPlaybackSavepoint(pSavepoint); Debug.Assert(rc != RC.DONE); } } return rc; }