diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/build.c | 25 | ||||
-rw-r--r-- | src/parse.y | 9 | ||||
-rw-r--r-- | src/pragma.c | 23 | ||||
-rw-r--r-- | src/sqliteInt.h | 3 | ||||
-rw-r--r-- | src/vdbe.c | 11 |
5 files changed, 33 insertions, 38 deletions
diff --git a/src/build.c b/src/build.c index be9c5c93b..c28f789ab 100644 --- a/src/build.c +++ b/src/build.c @@ -22,7 +22,7 @@ ** COMMIT ** ROLLBACK ** -** $Id: build.c,v 1.424 2007/05/04 16:14:38 drh Exp $ +** $Id: build.c,v 1.425 2007/05/04 18:30:41 drh Exp $ */ #include "sqliteInt.h" #include <ctype.h> @@ -3351,26 +3351,3 @@ KeyInfo *sqlite3IndexKeyinfo(Parse *pParse, Index *pIdx){ } return pKey; } - -#ifndef SQLITE_OMIT_AUTOVACUUM -/* -** This is called to compile a statement of the form "INCREMENTAL VACUUM". -*/ -void sqlite3IncrVacuum(Parse *pParse, Token *pLimit){ - Vdbe *v = sqlite3GetVdbe(pParse); - int iLimit; - if( pLimit==0 || !sqlite3GetInt32((char*)pLimit->z, &iLimit) ){ - iLimit = 0x7fffffff; - } - if( v ){ - int addr; - sqlite3BeginWriteOperation(pParse, 0, 0); - sqlite3VdbeAddOp(v, OP_MemInt, iLimit, 0); - addr = sqlite3VdbeAddOp(v, OP_IncrVacuum, 0, 0); - sqlite3VdbeAddOp(v, OP_Callback, 0, 0); - sqlite3VdbeAddOp(v, OP_MemIncr, -1, 0); - sqlite3VdbeAddOp(v, OP_IfMemPos, 0, addr); - sqlite3VdbeJumpHere(v, addr); - } -} -#endif /* #ifndef SQLITE_OMIT_AUTOVACUUM */ diff --git a/src/parse.y b/src/parse.y index 277561588..b69727118 100644 --- a/src/parse.y +++ b/src/parse.y @@ -14,7 +14,7 @@ ** the parser. Lemon will also generate a header file containing ** numeric codes for all of the tokens. ** -** @(#) $Id: parse.y,v 1.221 2007/05/04 16:14:38 drh Exp $ +** @(#) $Id: parse.y,v 1.222 2007/05/04 18:30:41 drh Exp $ */ // All token codes are small integers with #defines that begin with "TK_" @@ -174,7 +174,7 @@ id(A) ::= ID(X). {A = X;} %fallback ID ABORT AFTER ANALYZE ASC ATTACH BEFORE BEGIN CASCADE CAST CONFLICT DATABASE DEFERRED DESC DETACH EACH END EXCLUSIVE EXPLAIN FAIL FOR - INCREMENTAL IGNORE IMMEDIATE INITIALLY INSTEAD LIKE_KW MATCH PLAN + IGNORE IMMEDIATE INITIALLY INSTEAD LIKE_KW MATCH PLAN QUERY KEY OF OFFSET PRAGMA RAISE REPLACE RESTRICT ROW TEMP TRIGGER VACUUM VIEW VIRTUAL %ifdef SQLITE_OMIT_COMPOUND_SELECT @@ -903,11 +903,6 @@ cmd ::= VACUUM nm. {sqlite3Vacuum(pParse);} %endif SQLITE_OMIT_ATTACH %endif SQLITE_OMIT_VACUUM -%ifndef SQLITE_OMIT_AUTOVACUUM -cmd ::= INCREMENTAL VACUUM. {sqlite3IncrVacuum(pParse, 0);} -cmd ::= INCREMENTAL VACUUM INTEGER(X). {sqlite3IncrVacuum(pParse, &X);} -%endif - ///////////////////////////// The PRAGMA command ///////////////////////////// // %ifndef SQLITE_OMIT_PRAGMA diff --git a/src/pragma.c b/src/pragma.c index 68fd9f18a..22720d919 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -11,7 +11,7 @@ ************************************************************************* ** This file contains code used to implement the PRAGMA command. ** -** $Id: pragma.c,v 1.133 2007/04/26 14:42:36 danielk1977 Exp $ +** $Id: pragma.c,v 1.134 2007/05/04 18:30:41 drh Exp $ */ #include "sqliteInt.h" #include "os.h" @@ -414,6 +414,27 @@ void sqlite3Pragma( }else #endif + /* + ** PRAGMA [database.]incremental_vacuum(N) + ** + ** Do N steps of incremental vacuuming on a database. + */ +#ifndef SQLITE_OMIT_AUTOVACUUM + if( sqlite3StrICmp(zLeft,"incremental_vacuum")==0 ){ + int iLimit, addr; + if( zRight==0 || !sqlite3GetInt32(zRight, &iLimit) || iLimit<=0 ){ + iLimit = 0x7fffffff; + } + sqlite3BeginWriteOperation(pParse, 0, iDb); + sqlite3VdbeAddOp(v, OP_MemInt, iLimit, 0); + addr = sqlite3VdbeAddOp(v, OP_IncrVacuum, iDb, 0); + sqlite3VdbeAddOp(v, OP_Callback, 0, 0); + sqlite3VdbeAddOp(v, OP_MemIncr, -1, 0); + sqlite3VdbeAddOp(v, OP_IfMemPos, 0, addr); + sqlite3VdbeJumpHere(v, addr); + }else +#endif + #ifndef SQLITE_OMIT_PAGER_PRAGMAS /* ** PRAGMA [database.]cache_size diff --git a/src/sqliteInt.h b/src/sqliteInt.h index b59bf5006..dc2cdd12e 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -11,7 +11,7 @@ ************************************************************************* ** Internal interface definitions for SQLite. ** -** @(#) $Id: sqliteInt.h,v 1.555 2007/05/04 16:14:38 drh Exp $ +** @(#) $Id: sqliteInt.h,v 1.556 2007/05/04 18:30:41 drh Exp $ */ #ifndef _SQLITEINT_H_ #define _SQLITEINT_H_ @@ -1914,7 +1914,6 @@ int sqlite3VtabBegin(sqlite3 *, sqlite3_vtab *); FuncDef *sqlite3VtabOverloadFunction(FuncDef*, int nArg, Expr*); void sqlite3InvalidFunction(sqlite3_context*,int,sqlite3_value**); int sqlite3Reprepare(Vdbe*); -void sqlite3IncrVacuum(Parse *pParse, Token*); #ifdef SQLITE_SSE #include "sseInt.h" diff --git a/src/vdbe.c b/src/vdbe.c index 83197c426..569a6ef25 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -43,7 +43,7 @@ ** in this file for details. If in doubt, do not deviate from existing ** commenting and indentation practices when changing or adding code. ** -** $Id: vdbe.c,v 1.606 2007/05/04 13:15:56 drh Exp $ +** $Id: vdbe.c,v 1.607 2007/05/04 18:30:41 drh Exp $ */ #include "sqliteInt.h" #include "os.h" @@ -4600,14 +4600,17 @@ case OP_Vacuum: { /* no-push */ #endif #if !defined(SQLITE_OMIT_AUTOVACUUM) -/* Opcode: IncrVacuum * P2 * +/* Opcode: IncrVacuum P1 P2 * ** ** Perform a single step of the incremental vacuum procedure on -** the main database. If the vacuum has finished, jump to instruction +** the P1 database. If the vacuum has finished, jump to instruction ** P2. Otherwise, fall through to the next instruction. */ case OP_IncrVacuum: { /* no-push */ - Btree *pBt = db->aDb[0].pBt; + Btree *pBt; + + assert( pOp->p1>=0 && pOp->p1<db->nDb ); + pBt = db->aDb[pOp->p1].pBt; rc = sqlite3BtreeIncrVacuum(pBt); if( rc==SQLITE_DONE ){ pc = pOp->p2 - 1; |