/ Check-in [f11b0ed4]
Login

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

Overview
Comment:Do not invoke btreeComputeFreeSpace() when not necessary.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | deferred-free-space
Files: files | file ages | folders
SHA3-256:f11b0ed47402034378ded2c60b82841b81cd1319cdb72d1ef052faef29a5294d
User & Date: drh 2019-02-11 22:50:01
Context
2019-02-12
00:58
Change an assert() into a NEVER(), since the condition is difficult to prove with certainty. Improved comment on the MemPage.nFree field. Closed-Leaf check-in: fec071b8 user: drh tags: deferred-free-space
2019-02-11
22:50
Do not invoke btreeComputeFreeSpace() when not necessary. check-in: f11b0ed4 user: drh tags: deferred-free-space
19:27
Improvements to comments. No changes to code. check-in: 16eb0fc8 user: drh tags: deferred-free-space
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/btree.c.

  7392   7392       /* Reinitialize page pTo so that the contents of the MemPage structure
  7393   7393       ** match the new data. The initialization of pTo can actually fail under
  7394   7394       ** fairly obscure circumstances, even though it is a copy of initialized 
  7395   7395       ** page pFrom.
  7396   7396       */
  7397   7397       pTo->isInit = 0;
  7398   7398       rc = btreeInitPage(pTo);
         7399  +    if( rc==SQLITE_OK ) rc = btreeComputeFreeSpace(pTo);
  7399   7400       if( rc!=SQLITE_OK ){
  7400   7401         *pRC = rc;
  7401   7402         return;
  7402   7403       }
  7403   7404     
  7404   7405       /* If this is an auto-vacuum database, update the pointer-map entries
  7405   7406       ** for any b-tree or overflow pages that pTo now contains the pointers to.
................................................................................
  8290   8291     VVA_ONLY( int balance_quick_called = 0 );
  8291   8292     VVA_ONLY( int balance_deeper_called = 0 );
  8292   8293   
  8293   8294     do {
  8294   8295       int iPage = pCur->iPage;
  8295   8296       MemPage *pPage = pCur->pPage;
  8296   8297   
  8297         -    if( pPage->nFree<0 ){
  8298         -      rc = btreeComputeFreeSpace(pPage);
  8299         -      if( rc ) break;
  8300         -    }
         8298  +    assert( pPage->nFree>=0 );
  8301   8299       if( iPage==0 ){
  8302   8300         if( pPage->nOverflow ){
  8303   8301           /* The root page of the b-tree is overfull. In this case call the
  8304   8302           ** balance_deeper() function to create a new child for the root-page
  8305   8303           ** and copy the current contents of the root-page to it. The
  8306   8304           ** next iteration of the do-loop will balance the child page.
  8307   8305           */