/ Check-in [d03d63d7]
Login

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

Overview
Comment:When searching a list of freelist trunk pages looking for a specific page to allocate, avoid unnecessary journalling of the unchanged trunk pages towards the start of the list.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: d03d63d77ed144ac2c02a0245c4b4b070b79c88e
User & Date: drh 2011-04-07 14:47:01
References
2011-04-07
15:24
Add test case to verify [d03d63d77e] works. check-in: bf78acb9 user: dan tags: trunk
Context
2011-04-07
15:24
Add test case to verify [d03d63d77e] works. check-in: bf78acb9 user: dan tags: trunk
14:47
When searching a list of freelist trunk pages looking for a specific page to allocate, avoid unnecessary journalling of the unchanged trunk pages towards the start of the list. check-in: d03d63d7 user: drh tags: trunk
14:05
Avoid running thread1.test or thread2.test if SQLITE_MUTEX_NOOP is defined. check-in: 532ae32e user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/btree.c.

  4815   4815           rc = btreeGetPage(pBt, iTrunk, &pTrunk, 0);
  4816   4816         }
  4817   4817         if( rc ){
  4818   4818           pTrunk = 0;
  4819   4819           goto end_allocate_page;
  4820   4820         }
  4821   4821   
  4822         -      k = get4byte(&pTrunk->aData[4]);
         4822  +      k = get4byte(&pTrunk->aData[4]); /* # of leaves on this trunk page */
  4823   4823         if( k==0 && !searchList ){
  4824   4824           /* The trunk has no leaves and the list is not being searched. 
  4825   4825           ** So extract the trunk page itself and use it as the newly 
  4826   4826           ** allocated page */
  4827   4827           assert( pPrevTrunk==0 );
  4828   4828           rc = sqlite3PagerWrite(pTrunk->pDbPage);
  4829   4829           if( rc ){
................................................................................
  4900   4900           TRACE(("ALLOCATE: %d trunk - %d free pages left\n", *pPgno, n-1));
  4901   4901   #endif
  4902   4902         }else if( k>0 ){
  4903   4903           /* Extract a leaf from the trunk */
  4904   4904           u32 closest;
  4905   4905           Pgno iPage;
  4906   4906           unsigned char *aData = pTrunk->aData;
  4907         -        rc = sqlite3PagerWrite(pTrunk->pDbPage);
  4908         -        if( rc ){
  4909         -          goto end_allocate_page;
  4910         -        }
  4911   4907           if( nearby>0 ){
  4912   4908             u32 i;
  4913   4909             int dist;
  4914   4910             closest = 0;
  4915   4911             dist = sqlite3AbsInt32(get4byte(&aData[8]) - nearby);
  4916   4912             for(i=1; i<k; i++){
  4917   4913               int d2 = sqlite3AbsInt32(get4byte(&aData[8+i*4]) - nearby);
................................................................................
  4933   4929           testcase( iPage==mxPage );
  4934   4930           if( !searchList || iPage==nearby ){
  4935   4931             int noContent;
  4936   4932             *pPgno = iPage;
  4937   4933             TRACE(("ALLOCATE: %d was leaf %d of %d on trunk %d"
  4938   4934                    ": %d more free pages\n",
  4939   4935                    *pPgno, closest+1, k, pTrunk->pgno, n-1));
         4936  +          rc = sqlite3PagerWrite(pTrunk->pDbPage);
         4937  +          if( rc ) goto end_allocate_page;
  4940   4938             if( closest<k-1 ){
  4941   4939               memcpy(&aData[8+closest*4], &aData[4+k*4], 4);
  4942   4940             }
  4943   4941             put4byte(&aData[4], k-1);
  4944         -          assert( sqlite3PagerIswriteable(pTrunk->pDbPage) );
  4945   4942             noContent = !btreeGetHasContent(pBt, *pPgno);
  4946   4943             rc = btreeGetPage(pBt, *pPgno, ppPage, noContent);
  4947   4944             if( rc==SQLITE_OK ){
  4948   4945               rc = sqlite3PagerWrite((*ppPage)->pDbPage);
  4949   4946               if( rc!=SQLITE_OK ){
  4950   4947                 releasePage(*ppPage);
  4951   4948               }
................................................................................
  5006   5003         releasePage(*ppPage);
  5007   5004         return SQLITE_CORRUPT_BKPT;
  5008   5005       }
  5009   5006       (*ppPage)->isInit = 0;
  5010   5007     }else{
  5011   5008       *ppPage = 0;
  5012   5009     }
         5010  +  assert( rc!=SQLITE_OK || sqlite3PagerIswriteable((*ppPage)->pDbPage) );
  5013   5011     return rc;
  5014   5012   }
  5015   5013   
  5016   5014   /*
  5017   5015   ** This function is used to add page iPage to the database file free-list. 
  5018   5016   ** It is assumed that the page is not already a part of the free-list.
  5019   5017   **