SQLite

Check-in [83395a3d]
Login

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

Overview
Comment:If a database becomes corrupted such that an index is out of sync with its table, make sure the corruption is detected and reported back. Do not assume that indices always contain rowids for valid table rows.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 83395a3d24f18170fc068d9e644291678694c3f0
User & Date: drh 2010-07-30 18:40:55
References
2010-08-01
22:25 Fixed ticket [168d0f71]: Segfault while reading database with a corrupt index plus 3 other changes (artifact: 184435bf user: drh)
Context
2010-08-01
22:41
Fix a typo in an error message of the TCL interface. (check-in: 8eadd7b8 user: drh tags: trunk)
2010-07-30
18:40
If a database becomes corrupted such that an index is out of sync with its table, make sure the corruption is detected and reported back. Do not assume that indices always contain rowids for valid table rows. (check-in: 83395a3d user: drh tags: trunk)
16:54
Fix typos in comments. No code or logic changes. (check-in: 15c294ca user: drh tags: trunk)
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/vdbeaux.c.

2396
2397
2398
2399
2400
2401
2402

2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
#ifdef SQLITE_TEST
    extern int sqlite3_search_count;
#endif
    assert( p->isTable );
    rc = sqlite3BtreeMovetoUnpacked(p->pCursor, 0, p->movetoTarget, 0, &res);
    if( rc ) return rc;
    p->lastRowid = p->movetoTarget;

    p->rowidIsValid = ALWAYS(res==0) ?1:0;
    if( NEVER(res<0) ){
      rc = sqlite3BtreeNext(p->pCursor, &res);
      if( rc ) return rc;
    }
#ifdef SQLITE_TEST
    sqlite3_search_count++;
#endif
    p->deferredMoveto = 0;
    p->cacheStatus = CACHE_STALE;
  }else if( ALWAYS(p->pCursor) ){
    int hasMoved;







>
|
<
<
<
<







2396
2397
2398
2399
2400
2401
2402
2403
2404




2405
2406
2407
2408
2409
2410
2411
#ifdef SQLITE_TEST
    extern int sqlite3_search_count;
#endif
    assert( p->isTable );
    rc = sqlite3BtreeMovetoUnpacked(p->pCursor, 0, p->movetoTarget, 0, &res);
    if( rc ) return rc;
    p->lastRowid = p->movetoTarget;
    if( res!=0 ) return SQLITE_CORRUPT_BKPT;
    p->rowidIsValid = 1;




#ifdef SQLITE_TEST
    sqlite3_search_count++;
#endif
    p->deferredMoveto = 0;
    p->cacheStatus = CACHE_STALE;
  }else if( ALWAYS(p->pCursor) ){
    int hasMoved;