/ Check-in [92858991]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix a page-cache reference leak in the btree balancer when there is a corrupt database.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | deferred-free-space
Files: files | file ages | folders
SHA3-256: 9285899120dec24ff2944431ad455d7ae217ef408ae2f1a3e7bdfb897099028c
User & Date: drh 2019-02-09 22:33:44
Context
2019-02-11
12:51
Updates to a comment to keep it in alignment to the changes on this branch. check-in: 7499f743 user: drh tags: deferred-free-space
2019-02-09
22:33
Fix a page-cache reference leak in the btree balancer when there is a corrupt database. check-in: 92858991 user: drh tags: deferred-free-space
21:06
Defer computing the MemPage.nFree value of an in-memory btree page until it is actually needed, since for many pages it is never needed. This checkin works sufficiently to prove the concept, but still has issues with exception handling. check-in: 1d43ee40 user: drh tags: deferred-free-space
Changes
Hide Diffs Side-by-Side Diffs Show Whitespace Changes Patch

Changes to src/btree.c.

  7546   7546       pRight = &pParent->aData[pParent->hdrOffset+8];
  7547   7547     }else{
  7548   7548       pRight = findCell(pParent, i+nxDiv-pParent->nOverflow);
  7549   7549     }
  7550   7550     pgno = get4byte(pRight);
  7551   7551     while( 1 ){
  7552   7552       rc = getAndInitPage(pBt, pgno, &apOld[i], 0, 0);
  7553         -    if( rc==0 && apOld[i]->nFree<0 ){
  7554         -      rc = btreeComputeFreeSpace(apOld[i]);
  7555         -    }
  7556   7553       if( rc ){
  7557   7554         memset(apOld, 0, (i+1)*sizeof(MemPage*));
  7558   7555         goto balance_cleanup;
         7556  +    }
         7557  +    if( apOld[i]->nFree<0 ){
         7558  +      rc = btreeComputeFreeSpace(apOld[i]);
         7559  +      if( rc ){
         7560  +        memset(apOld, 0, (i)*sizeof(MemPage*));
         7561  +        goto balance_cleanup;
         7562  +      }
  7559   7563       }
  7560   7564       nMaxCells += 1+apOld[i]->nCell+apOld[i]->nOverflow;
  7561   7565       if( (i--)==0 ) break;
  7562   7566   
  7563   7567       if( pParent->nOverflow && i+nxDiv==pParent->aiOvfl[0] ){
  7564   7568         apDiv[i] = pParent->apOvfl[0];
  7565   7569         pgno = get4byte(apDiv[i]);