/ Check-in [716fccea]
Login

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

Overview
Comment:Additional simplifications to btree.c in support of coverage testing. (CVS 6915)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 716fccea58c4c217e68e04e0776e44ae39c11950
User & Date: drh 2009-07-21 19:02:21
Context
2009-07-21
19:25
Change getAndInitPage() (btree.c) to use only PagerAcquire(), not PagerLookup() and PagerAcquire(). (CVS 6916) check-in: 0b41dfc0 user: danielk1977 tags: trunk
19:02
Additional simplifications to btree.c in support of coverage testing. (CVS 6915) check-in: 716fccea user: drh tags: trunk
15:33
Remove an assert() in btree.c which is no longer true due to changes in the error reporting behavior of ptrmapPut(). (CVS 6914) check-in: 110998f1 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/btree.c.

     5      5   ** a legal notice, here is a blessing:
     6      6   **
     7      7   **    May you do good and not evil.
     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12         -** $Id: btree.c,v 1.695 2009/07/21 15:33:14 drh Exp $
           12  +** $Id: btree.c,v 1.696 2009/07/21 19:02:21 drh Exp $
    13     13   **
    14     14   ** This file implements a external (disk-based) database using BTrees.
    15     15   ** See the header comment on "btreeInt.h" for additional information.
    16     16   ** Including a description of file format and an overview of operation.
    17     17   */
    18     18   #include "btreeInt.h"
    19     19   
................................................................................
  3853   3853     u32 nLocal;
  3854   3854   
  3855   3855     assert( pCur!=0 && pCur->iPage>=0 && pCur->apPage[pCur->iPage]);
  3856   3856     assert( pCur->eState==CURSOR_VALID );
  3857   3857     assert( cursorHoldsMutex(pCur) );
  3858   3858     pPage = pCur->apPage[pCur->iPage];
  3859   3859     assert( pCur->aiIdx[pCur->iPage]<pPage->nCell );
  3860         -  getCellInfo(pCur);
         3860  +  if( NEVER(pCur->info.nSize==0) ){
         3861  +    btreeParseCell(pCur->apPage[pCur->iPage], pCur->aiIdx[pCur->iPage],
         3862  +                   &pCur->info);
         3863  +  }
  3861   3864     aPayload = pCur->info.pCell;
  3862   3865     aPayload += pCur->info.nHeader;
  3863   3866     if( pPage->intKey ){
  3864   3867       nKey = 0;
  3865   3868     }else{
  3866   3869       nKey = (int)pCur->info.nKey;
  3867   3870     }
  3868   3871     if( skipKey ){
  3869   3872       aPayload += nKey;
  3870   3873       nLocal = pCur->info.nLocal - nKey;
  3871   3874     }else{
  3872   3875       nLocal = pCur->info.nLocal;
  3873         -    if( nLocal>nKey ){
  3874         -      nLocal = nKey;
  3875         -    }
         3876  +    assert( nLocal<=nKey );
  3876   3877     }
  3877   3878     *pAmt = nLocal;
  3878   3879     return aPayload;
  3879   3880   }
  3880   3881   
  3881   3882   
  3882   3883   /*
................................................................................
  3890   3891   ** Hence, a mutex on the BtShared should be held prior to calling
  3891   3892   ** this routine.
  3892   3893   **
  3893   3894   ** These routines is used to get quick access to key and data
  3894   3895   ** in the common case where no overflow pages are used.
  3895   3896   */
  3896   3897   const void *sqlite3BtreeKeyFetch(BtCursor *pCur, int *pAmt){
         3898  +  const void *p = 0;
  3897   3899     assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) );
  3898   3900     assert( cursorHoldsMutex(pCur) );
  3899         -  if( pCur->eState==CURSOR_VALID ){
  3900         -    return (const void*)fetchPayload(pCur, pAmt, 0);
         3901  +  if( ALWAYS(pCur->eState==CURSOR_VALID) ){
         3902  +    p = (const void*)fetchPayload(pCur, pAmt, 0);
  3901   3903     }
  3902         -  return 0;
         3904  +  return p;
  3903   3905   }
  3904   3906   const void *sqlite3BtreeDataFetch(BtCursor *pCur, int *pAmt){
         3907  +  const void *p = 0;
  3905   3908     assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) );
  3906   3909     assert( cursorHoldsMutex(pCur) );
  3907         -  if( pCur->eState==CURSOR_VALID ){
  3908         -    return (const void*)fetchPayload(pCur, pAmt, 1);
         3910  +  if( ALWAYS(pCur->eState==CURSOR_VALID) ){
         3911  +    p = (const void*)fetchPayload(pCur, pAmt, 1);
  3909   3912     }
  3910         -  return 0;
         3913  +  return p;
  3911   3914   }
  3912   3915   
  3913   3916   
  3914   3917   /*
  3915   3918   ** Move the cursor down to a new child page.  The newPgno argument is the
  3916   3919   ** page number of the child page to move to.
  3917   3920   **
................................................................................
  6977   6980             return rc;
  6978   6981           }
  6979   6982           rc = relocatePage(pBt, pMove, PTRMAP_ROOTPAGE, 0, iTable, 0);
  6980   6983           releasePage(pMove);
  6981   6984           if( rc!=SQLITE_OK ){
  6982   6985             return rc;
  6983   6986           }
         6987  +        pMove = 0;
  6984   6988           rc = btreeGetPage(pBt, maxRootPgno, &pMove, 0);
  6985   6989           freePage(pMove, &rc);
  6986   6990           releasePage(pMove);
  6987   6991           if( rc!=SQLITE_OK ){
  6988   6992             return rc;
  6989   6993           }
  6990   6994           *piMoved = maxRootPgno;