aboutsummaryrefslogtreecommitdiff
path: root/src/pcache.c
diff options
context:
space:
mode:
authordrh <>2022-09-02 15:09:55 +0000
committerdrh <>2022-09-02 15:09:55 +0000
commit5fc3a8a32fe76b50f39b73b1c6fbc4827e68529f (patch)
tree450a7323b2f6841f3a7d448c191bb61c6eed2c6a /src/pcache.c
parent4e9bf5ace34a29d04386bfa9bcdda1861750b744 (diff)
downloadsqlite-5fc3a8a32fe76b50f39b73b1c6fbc4827e68529f.tar.gz
sqlite-5fc3a8a32fe76b50f39b73b1c6fbc4827e68529f.zip
If sqlite3PcacheMove() really performs a swap, then be sure to renumber the
second page. FossilOrigin-Name: 81cff9f1955874aade55daa94263f58f06d966bd51ad558755f92777069a7347
Diffstat (limited to 'src/pcache.c')
-rw-r--r--src/pcache.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/pcache.c b/src/pcache.c
index 38093dd7a..8c57f5b1e 100644
--- a/src/pcache.c
+++ b/src/pcache.c
@@ -649,11 +649,20 @@ void sqlite3PcacheClearSyncFlags(PCache *pCache){
*/
void sqlite3PcacheMove(PgHdr *p, Pgno newPgno){
PCache *pCache = p->pCache;
+ sqlite3_pcache_page *pOther;
assert( p->nRef>0 );
assert( newPgno>0 );
assert( sqlite3PcachePageSanity(p) );
pcacheTrace(("%p.MOVE %d -> %d\n",pCache,p->pgno,newPgno));
+ pOther = sqlite3GlobalConfig.pcache2.xFetch(pCache->pCache, newPgno, 0);
sqlite3GlobalConfig.pcache2.xRekey(pCache->pCache, p->pPage, p->pgno,newPgno);
+ if( pOther ){
+ PgHdr *pPg = (PgHdr*)pOther->pExtra;
+ pPg->pgno = p->pgno;
+ if( pPg->pPage==0 ){
+ sqlite3GlobalConfig.pcache2.xUnpin(pCache->pCache, pOther, 0);
+ }
+ }
p->pgno = newPgno;
if( (p->flags&PGHDR_DIRTY) && (p->flags&PGHDR_NEED_SYNC) ){
pcacheManageDirtyList(p, PCACHE_DIRTYLIST_FRONT);