/ Check-in [52b02ca5]
Login

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

Overview
Comment:If the root page of a btree is empty and is also not a leaf page and the page is not page 1, then report database corruption. (CVS 6716)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:52b02ca5f3e5fdf2f3e02e9d8e016028d0842818
User & Date: drh 2009-06-04 16:14:34
Context
2009-06-04
17:02
Fix an assertion fault in balance_quick() that occurs when an interior btree node has zero cells due to database corruption. Also update the corrupt7.test result vectors for a couple of cases where the error report on database corruption changed due to earlier detection. (CVS 6717) check-in: 1335e444 user: drh tags: trunk
16:14
If the root page of a btree is empty and is also not a leaf page and the page is not page 1, then report database corruption. (CVS 6716) check-in: 52b02ca5 user: drh tags: trunk
14:46
Reduce the stack usage of balance_quick(). (CVS 6715) check-in: e7ad68e9 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.614 2009/06/04 14:46:08 danielk1977 Exp $
           12  +** $Id: btree.c,v 1.615 2009/06/04 16:14:34 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   
................................................................................
  3861   3861     pCur->aiIdx[0] = 0;
  3862   3862     pCur->info.nSize = 0;
  3863   3863     pCur->atLast = 0;
  3864   3864     pCur->validNKey = 0;
  3865   3865   
  3866   3866     if( pRoot->nCell==0 && !pRoot->leaf ){
  3867   3867       Pgno subpage;
         3868  +    if( pRoot->pgno!=1 ) return SQLITE_CORRUPT_BKPT;
  3868   3869       assert( pRoot->pgno==1 );
  3869   3870       subpage = get4byte(&pRoot->aData[pRoot->hdrOffset+8]);
  3870   3871       assert( subpage>0 );
  3871   3872       pCur->eState = CURSOR_VALID;
  3872   3873       rc = moveToChild(pCur, subpage);
  3873   3874     }else{
  3874   3875       pCur->eState = ((pRoot->nCell>0)?CURSOR_VALID:CURSOR_INVALID);