1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-07 02:42:48 +03:00

Add some tests (and 2 resulting bug fixes) to incr vacuum mode. (CVS 3885)

FossilOrigin-Name: 89b1b3f897bda1fffceb9cf72fa4d42b809ccb8e
This commit is contained in:
danielk1977
2007-04-28 15:47:43 +00:00
parent 8ffcadb57e
commit b4626a3e16
9 changed files with 142 additions and 22 deletions

View File

@@ -9,7 +9,7 @@
** May you share freely, never taking more than you give.
**
*************************************************************************
** $Id: btree.c,v 1.360 2007/04/27 07:05:44 danielk1977 Exp $
** $Id: btree.c,v 1.361 2007/04/28 15:47:44 danielk1977 Exp $
**
** This file implements a external (disk-based) database using BTrees.
** For a detailed discussion of BTrees, refer to
@@ -2366,6 +2366,13 @@ static int incrVacuumStep(BtShared *pBt, Pgno nFin){
return rc;
}
/* If nFin is zero, this loop runs exactly once and page pLastPg
** is swapped with the first free page pulled off the free list.
**
** On the other hand, if nFin is greater than zero, then keep
** looping until a free-page located within the first nFin pages
** of the file is found.
*/
do {
MemPage *pFreePg;
rc = allocateBtreePage(pBt, &pFreePg, &iFreePg, 0, 0);
@@ -2376,7 +2383,11 @@ static int incrVacuumStep(BtShared *pBt, Pgno nFin){
releasePage(pFreePg);
}while( nFin!=0 && iFreePg>nFin );
assert( iFreePg<iLastPg );
rc = sqlite3PagerWrite(pLastPg->pDbPage);
if( rc!=SQLITE_OK ){
return rc;
}
rc = relocatePage(pBt, pLastPg, eType, iPtrPage, iFreePg);
releasePage(pLastPg);
if( rc!=SQLITE_OK ){
@@ -2431,8 +2442,6 @@ static int autoVacuumCommit(BtShared *pBt, Pgno *pnTrunc){
if( !pBt->incrVacuum ){
Pgno nFin = 0;
if( pBt->nTrunc==0 ){
Pgno nFree;
Pgno nPtrmap;