diff options
author | dan <Dan Kennedy> | 2022-11-28 18:41:41 +0000 |
---|---|---|
committer | dan <Dan Kennedy> | 2022-11-28 18:41:41 +0000 |
commit | 1b3d13e65e125500d1034e889b37363baa8f1e38 (patch) | |
tree | 81840dd9a80fe5015dbd1ae798fe620876f38667 /ext/recover/sqlite3recover.c | |
parent | e862b5fe1d2bda6ef7d557471c150c82ec453455 (diff) | |
download | sqlite-1b3d13e65e125500d1034e889b37363baa8f1e38.tar.gz sqlite-1b3d13e65e125500d1034e889b37363baa8f1e38.zip |
Add the SQLITE_FCNTL_RESET_CACHE verb. Use it to ensure that the page cache is purged before and after a the recovery extension is run.
FossilOrigin-Name: 6db0bc4bc0d272b610bef2aeeae43f539ed6e7cc0a9cc767d5af85ecb0019d5f
Diffstat (limited to 'ext/recover/sqlite3recover.c')
-rw-r--r-- | ext/recover/sqlite3recover.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/ext/recover/sqlite3recover.c b/ext/recover/sqlite3recover.c index 30260f014..e62aba752 100644 --- a/ext/recover/sqlite3recover.c +++ b/ext/recover/sqlite3recover.c @@ -2017,6 +2017,7 @@ static void recoverFinalCleanup(sqlite3_recover *p){ p->pTblList = 0; sqlite3_finalize(p->pGetPage); p->pGetPage = 0; + sqlite3_file_control(p->dbIn, p->zDb, SQLITE_FCNTL_RESET_CACHE, 0); { #ifndef NDEBUG @@ -2315,6 +2316,7 @@ static int recoverVfsRead(sqlite3_file *pFd, void *aBuf, int nByte, i64 iOff){ ** ** + first freelist page (32-bits at offset 32) ** + size of freelist (32-bits at offset 36) + ** + the wal-mode flags (16-bits at offset 18) ** ** We also try to preserve the auto-vacuum, incr-value, user-version ** and application-id fields - all 32 bit quantities at offsets @@ -2378,7 +2380,8 @@ static int recoverVfsRead(sqlite3_file *pFd, void *aBuf, int nByte, i64 iOff){ if( p->pPage1Cache ){ p->pPage1Disk = &p->pPage1Cache[nByte]; memcpy(p->pPage1Disk, aBuf, nByte); - + aHdr[18] = a[18]; + aHdr[19] = a[19]; recoverPutU32(&aHdr[28], dbsz); recoverPutU32(&aHdr[56], enc); recoverPutU16(&aHdr[105], pgsz-nReserve); @@ -2574,6 +2577,7 @@ static void recoverStep(sqlite3_recover *p){ recoverOpenOutput(p); /* Open transactions on both the input and output databases. */ + sqlite3_file_control(p->dbIn, p->zDb, SQLITE_FCNTL_RESET_CACHE, 0); recoverExec(p, p->dbIn, "PRAGMA writable_schema = on"); recoverExec(p, p->dbIn, "BEGIN"); if( p->errCode==SQLITE_OK ) p->bCloseTransaction = 1; |