/ Check-in [2a3f5ce1]
Login

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

Overview
Comment:Fix integrity check so that it always reports memory allocation errors that it encounters. (CVS 5984)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 2a3f5ce14c050b135ab9d2247aee84ca37882c4b
User & Date: drh 2008-12-05 22:40:08
Context
2008-12-05
23:40
Make the minimum allocate size for RowSet objects large enough to accommodate 8-byte pointers. (CVS 5985) check-in: b74885e0 user: drh tags: trunk
22:40
Fix integrity check so that it always reports memory allocation errors that it encounters. (CVS 5984) check-in: 2a3f5ce1 user: drh tags: trunk
20:01
Make sure the nOverflow flag in MemPage is reset to zero after every insert. (CVS 5983) check-in: bfde3dae 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.544 2008/12/05 20:01:43 drh Exp $
           12  +** $Id: btree.c,v 1.545 2008/12/05 22:40:08 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   
................................................................................
  6698   6698   ){
  6699   6699     int rc;
  6700   6700     u8 ePtrmapType;
  6701   6701     Pgno iPtrmapParent;
  6702   6702   
  6703   6703     rc = ptrmapGet(pCheck->pBt, iChild, &ePtrmapType, &iPtrmapParent);
  6704   6704     if( rc!=SQLITE_OK ){
         6705  +    if( rc==SQLITE_NOMEM ) pCheck->mallocFailed = 1;
  6705   6706       checkAppendMsg(pCheck, zContext, "Failed to read ptrmap key=%d", iChild);
  6706   6707       return;
  6707   6708     }
  6708   6709   
  6709   6710     if( ePtrmapType!=eType || iPtrmapParent!=iParent ){
  6710   6711       checkAppendMsg(pCheck, zContext, 
  6711   6712         "Bad ptr map entry key=%d expected=(%d,%d) got=(%d,%d)", 
................................................................................
  6824   6825     /* Check that the page exists
  6825   6826     */
  6826   6827     pBt = pCheck->pBt;
  6827   6828     usableSize = pBt->usableSize;
  6828   6829     if( iPage==0 ) return 0;
  6829   6830     if( checkRef(pCheck, iPage, zParentContext) ) return 0;
  6830   6831     if( (rc = sqlite3BtreeGetPage(pBt, (Pgno)iPage, &pPage, 0))!=0 ){
         6832  +    if( rc==SQLITE_NOMEM ) pCheck->mallocFailed = 1;
  6831   6833       checkAppendMsg(pCheck, zContext,
  6832   6834          "unable to get the page. error code=%d", rc);
  6833   6835       return 0;
  6834   6836     }
  6835   6837     if( (rc = sqlite3BtreeInitPage(pPage))!=0 ){
         6838  +    if( rc==SQLITE_NOMEM ) pCheck->mallocFailed = 1;
  6836   6839       checkAppendMsg(pCheck, zContext, 
  6837   6840                      "sqlite3BtreeInitPage() returns error code %d", rc);
  6838   6841       releasePage(pPage);
  6839   6842       return 0;
  6840   6843     }
  6841   6844   
  6842   6845     /* Check out all the cells.
................................................................................
  6965   6968   #ifndef SQLITE_OMIT_INTEGRITY_CHECK
  6966   6969   /*
  6967   6970   ** This routine does a complete check of the given BTree file.  aRoot[] is
  6968   6971   ** an array of pages numbers were each page number is the root page of
  6969   6972   ** a table.  nRoot is the number of entries in aRoot.
  6970   6973   **
  6971   6974   ** Write the number of error seen in *pnErr.  Except for some memory
  6972         -** allocation errors,  nn error message is held in memory obtained from
         6975  +** allocation errors,  an error message held in memory obtained from
  6973   6976   ** malloc is returned if *pnErr is non-zero.  If *pnErr==0 then NULL is
  6974         -** returned.
         6977  +** returned.  If a memory allocation error occurs, NULL is returned.
  6975   6978   */
  6976   6979   char *sqlite3BtreeIntegrityCheck(
  6977   6980     Btree *p,     /* The btree to be checked */
  6978   6981     int *aRoot,   /* An array of root pages numbers for individual trees */
  6979   6982     int nRoot,    /* Number of entries in aRoot[] */
  6980   6983     int mxErr,    /* Stop reporting errors after this many */
  6981   6984     int *pnErr    /* Write number of errors seen to this variable */