SQLite

Check-in [56ff336e0a]
Login

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

Overview
Comment:Two more places where logging of freelist trunk pages is needed.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | experimentalIoLog
Files: files | file ages | folders
SHA1: 56ff336e0ae258f4ac0b221602012f5fa9b4fc13
User & Date: drh 2015-08-11 01:45:40.842
Context
2015-08-11
10:59
Add a tcl interface for the experimental logging functionality. (check-in: e844304de7 user: dan tags: experimentalIoLog)
01:45
Two more places where logging of freelist trunk pages is needed. (check-in: 56ff336e0a user: drh tags: experimentalIoLog)
2015-08-10
20:53
Record when an allocated page is taken from the freelist trunk. (check-in: bb5d7782bd user: drh tags: experimentalIoLog)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/btree.c.
5543
5544
5545
5546
5547
5548
5549



5550
5551
5552
5553
5554
5555
5556
      }else{
        rc = btreeGetUnusedPage(pBt, iTrunk, &pTrunk, 0);
      }
      if( rc ){
        pTrunk = 0;
        goto end_allocate_page;
      }



      assert( pTrunk!=0 );
      assert( pTrunk->aData!=0 );
      /* EVIDENCE-OF: R-13523-04394 The second integer on a freelist trunk page
      ** is the number of leaf page pointers to follow. */
      k = get4byte(&pTrunk->aData[4]);
      if( k==0 && !searchList ){
        /* The trunk has no leaves and the list is not being searched. 







>
>
>







5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
      }else{
        rc = btreeGetUnusedPage(pBt, iTrunk, &pTrunk, 0);
      }
      if( rc ){
        pTrunk = 0;
        goto end_allocate_page;
      }
      if( pBt->pLog ){
        sqlite3ExperimentalLog(pBt->pLog, "freelist-trunk %d", iTrunk);
      }
      assert( pTrunk!=0 );
      assert( pTrunk->aData!=0 );
      /* EVIDENCE-OF: R-13523-04394 The second integer on a freelist trunk page
      ** is the number of leaf page pointers to follow. */
      k = get4byte(&pTrunk->aData[4]);
      if( k==0 && !searchList ){
        /* The trunk has no leaves and the list is not being searched. 
5848
5849
5850
5851
5852
5853
5854



5855
5856
5857
5858
5859
5860
5861

    nLeaf = get4byte(&pTrunk->aData[4]);
    assert( pBt->usableSize>32 );
    if( nLeaf > (u32)pBt->usableSize/4 - 2 ){
      rc = SQLITE_CORRUPT_BKPT;
      goto freepage_out;
    }



    if( nLeaf < (u32)pBt->usableSize/4 - 8 ){
      /* In this case there is room on the trunk page to insert the page
      ** being freed as a new leaf.
      **
      ** Note that the trunk page is not really full until it contains
      ** usableSize/4 - 2 entries, not usableSize/4 - 8 entries as we have
      ** coded.  But due to a coding error in versions of SQLite prior to







>
>
>







5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867

    nLeaf = get4byte(&pTrunk->aData[4]);
    assert( pBt->usableSize>32 );
    if( nLeaf > (u32)pBt->usableSize/4 - 2 ){
      rc = SQLITE_CORRUPT_BKPT;
      goto freepage_out;
    }
    if( pBt->pLog ){
      sqlite3ExperimentalLog(pBt->pLog, "freelist-trunk %d", iTrunk);
    }
    if( nLeaf < (u32)pBt->usableSize/4 - 8 ){
      /* In this case there is room on the trunk page to insert the page
      ** being freed as a new leaf.
      **
      ** Note that the trunk page is not really full until it contains
      ** usableSize/4 - 2 entries, not usableSize/4 - 8 entries as we have
      ** coded.  But due to a coding error in versions of SQLite prior to