diff options
author | drh <drh@noemail.net> | 2005-02-26 17:31:26 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2005-02-26 17:31:26 +0000 |
commit | ccae6026e6b817121bee172fd9e29a6aa67ca8d6 (patch) | |
tree | 240216cff1844d6779b6f7f31936ee1440444bcc /src/btree.c | |
parent | 75308731329019295e4230dd179af84f307cfb1d (diff) | |
download | sqlite-ccae6026e6b817121bee172fd9e29a6aa67ca8d6.tar.gz sqlite-ccae6026e6b817121bee172fd9e29a6aa67ca8d6.zip |
Fix an assertion fault that can occur while autovacuuming a corrupt database
file. Add the SQLITE_OMIT_COMPLETE compile-time parameter. (CVS 2361)
FossilOrigin-Name: bb0e7e3857a06347b08d93553ac603e737322262
Diffstat (limited to 'src/btree.c')
-rw-r--r-- | src/btree.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/btree.c b/src/btree.c index 1a5062a6e..f68766e8d 100644 --- a/src/btree.c +++ b/src/btree.c @@ -9,7 +9,7 @@ ** May you share freely, never taking more than you give. ** ************************************************************************* -** $Id: btree.c,v 1.248 2005/02/15 16:23:02 drh Exp $ +** $Id: btree.c,v 1.249 2005/02/26 17:31:27 drh Exp $ ** ** This file implements a external (disk-based) database using BTrees. ** For a detailed discussion of BTrees, refer to @@ -1843,7 +1843,10 @@ static int autoVacuumCommit(Btree *pBt, Pgno *nTrunc){ rc = ptrmapGet(pBt, iDbPage, &eType, &iPtrPage); if( rc!=SQLITE_OK ) goto autovacuum_out; - assert( eType!=PTRMAP_ROOTPAGE ); + if( eType==PTRMAP_ROOTPAGE ){ + rc = SQLITE_CORRUPT; + goto autovacuum_out; + } /* If iDbPage is free, do not swap it. */ if( eType==PTRMAP_FREEPAGE ){ @@ -4690,12 +4693,12 @@ int sqlite3BtreeCreateTable(Btree *pBt, int *piTable, int flags){ return rc; } rc = ptrmapGet(pBt, pgnoRoot, &eType, &iPtrPage); - assert( eType!=PTRMAP_ROOTPAGE ); - assert( eType!=PTRMAP_FREEPAGE ); - if( rc!=SQLITE_OK ){ + if( rc!=SQLITE_OK || eType==PTRMAP_ROOTPAGE || eType==PTRMAP_FREEPAGE ){ releasePage(pRoot); return rc; } + assert( eType!=PTRMAP_ROOTPAGE ); + assert( eType!=PTRMAP_FREEPAGE ); rc = relocatePage(pBt, pRoot, eType, iPtrPage, pgnoMove); releasePage(pRoot); if( rc!=SQLITE_OK ){ |