mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-29 08:01:23 +03:00
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
This commit is contained in:
@ -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;
|
||||
|
Reference in New Issue
Block a user