/ Check-in [196cbf82]
Login

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

Overview
Comment:Comment out sqlite3BtreeFlags() when not in debug mode. Tweaks to database corruption detection logic in freeSpace(). (CVS 6861)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 196cbf82290a308e78b13044d0fae993f2d5cb90
User & Date: drh 2009-07-08 15:14:50
Context
2009-07-08
16:54
Improvements to comments in btree.c:freeSpace(). Added a testcase() macro to verify a boundary case is tested in sqlite3BtreeInitPage(). (CVS 6862) check-in: 5ac991b3 user: drh tags: trunk
15:14
Comment out sqlite3BtreeFlags() when not in debug mode. Tweaks to database corruption detection logic in freeSpace(). (CVS 6861) check-in: 196cbf82 user: drh tags: trunk
13:55
Fix error handling in sqlite3BtreePutData(). (CVS 6860) check-in: 86eba4f1 user: danielk1977 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.660 2009/07/08 13:55:29 danielk1977 Exp $
           12  +** $Id: btree.c,v 1.661 2009/07/08 15:14:50 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   
................................................................................
  1064   1064         return SQLITE_CORRUPT_BKPT;
  1065   1065       }
  1066   1066   #else
  1067   1067       if( cbrk<iCellFirst || pc+size>usableSize ){
  1068   1068         return SQLITE_CORRUPT_BKPT;
  1069   1069       }
  1070   1070   #endif
  1071         -    assert( cbrk+size<=usableSize && cbrk>=iCellFirst );
         1071  +    assert( cbrk+size<=usableSize && cbrk>iCellFirst );
  1072   1072       testcase( cbrk+size==usableSize );
  1073         -    testcase( cbrk==iCellFirst );
  1074   1073       testcase( pc+size==usableSize );
  1075   1074       memcpy(&data[cbrk], &temp[pc], size);
  1076   1075       put2byte(pAddr, cbrk);
  1077   1076     }
  1078   1077     assert( cbrk>=iCellFirst );
  1079   1078     put2byte(&data[hdr+5], cbrk);
  1080   1079     data[hdr+1] = 0;
................................................................................
  1211   1210     ** freeblocks that overlapped cells.  If there was overlap then
  1212   1211     ** subsequent insert operations might have corrupted the freelist.
  1213   1212     ** So we do need to check for corruption while scanning the freelist.
  1214   1213     */
  1215   1214     hdr = pPage->hdrOffset;
  1216   1215     addr = hdr + 1;
  1217   1216     iLast = pPage->pBt->usableSize - 4;
         1217  +  assert( start<=iLast );
  1218   1218     while( (pbegin = get2byte(&data[addr]))<start && pbegin>0 ){
  1219         -    if( pbegin>iLast || pbegin<addr+4 ){
         1219  +    if( pbegin<addr+4 ){
  1220   1220         return SQLITE_CORRUPT_BKPT;
  1221   1221       }
  1222   1222       addr = pbegin;
  1223   1223     }
  1224   1224     if( pbegin>iLast ){
  1225   1225       return SQLITE_CORRUPT_BKPT;
  1226   1226     }
................................................................................
  7040   7040       }
  7041   7041   #endif
  7042   7042     }
  7043   7043     sqlite3BtreeLeave(p);
  7044   7044     return rc;
  7045   7045   }
  7046   7046   
         7047  +#ifndef SQLITE_TEST
  7047   7048   /*
  7048   7049   ** Return the flag byte at the beginning of the page that the cursor
  7049   7050   ** is currently pointing to.
  7050   7051   */
  7051   7052   int sqlite3BtreeFlags(BtCursor *pCur){
  7052   7053     /* TODO: What about CURSOR_REQUIRESEEK state? Probably need to call
  7053   7054     ** restoreCursorPosition() here.
................................................................................
  7056   7057     restoreCursorPosition(pCur);
  7057   7058     pPage = pCur->apPage[pCur->iPage];
  7058   7059     assert( cursorHoldsMutex(pCur) );
  7059   7060     assert( pPage!=0 );
  7060   7061     assert( pPage->pBt==pCur->pBt );
  7061   7062     return pPage->aData[pPage->hdrOffset];
  7062   7063   }
         7064  +#endif
  7063   7065   
  7064   7066   #ifndef SQLITE_OMIT_BTREECOUNT
  7065   7067   /*
  7066   7068   ** The first argument, pCur, is a cursor opened on some b-tree. Count the
  7067   7069   ** number of entries in the b-tree and write the result to *pnEntry.
  7068   7070   **
  7069   7071   ** SQLITE_OK is returned if the operation is successfully executed.