SQLite

Check-in [f11b0ed474]
Login

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

Overview
Comment:Do not invoke btreeComputeFreeSpace() when not necessary.
Downloads: Tarball | ZIP 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.937
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: fec071b89d user: drh tags: deferred-free-space)
2019-02-11
22:50
Do not invoke btreeComputeFreeSpace() when not necessary. (check-in: f11b0ed474 user: drh tags: deferred-free-space)
19:27
Improvements to comments. No changes to code. (check-in: 16eb0fc8f8 user: drh tags: deferred-free-space)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/btree.c.
7392
7393
7394
7395
7396
7397
7398

7399
7400
7401
7402
7403
7404
7405
    /* Reinitialize page pTo so that the contents of the MemPage structure
    ** match the new data. The initialization of pTo can actually fail under
    ** fairly obscure circumstances, even though it is a copy of initialized 
    ** page pFrom.
    */
    pTo->isInit = 0;
    rc = btreeInitPage(pTo);

    if( rc!=SQLITE_OK ){
      *pRC = rc;
      return;
    }
  
    /* If this is an auto-vacuum database, update the pointer-map entries
    ** for any b-tree or overflow pages that pTo now contains the pointers to.







>







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

  do {
    int iPage = pCur->iPage;
    MemPage *pPage = pCur->pPage;

    if( pPage->nFree<0 ){
      rc = btreeComputeFreeSpace(pPage);
      if( rc ) break;
    }
    if( iPage==0 ){
      if( pPage->nOverflow ){
        /* The root page of the b-tree is overfull. In this case call the
        ** balance_deeper() function to create a new child for the root-page
        ** and copy the current contents of the root-page to it. The
        ** next iteration of the do-loop will balance the child page.
        */ 







|
<
<
<







8291
8292
8293
8294
8295
8296
8297
8298



8299
8300
8301
8302
8303
8304
8305
  VVA_ONLY( int balance_quick_called = 0 );
  VVA_ONLY( int balance_deeper_called = 0 );

  do {
    int iPage = pCur->iPage;
    MemPage *pPage = pCur->pPage;

    assert( pPage->nFree>=0 );



    if( iPage==0 ){
      if( pPage->nOverflow ){
        /* The root page of the b-tree is overfull. In this case call the
        ** balance_deeper() function to create a new child for the root-page
        ** and copy the current contents of the root-page to it. The
        ** next iteration of the do-loop will balance the child page.
        */