1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-08 03:22:21 +03:00

Change incremental vacuum to be triggered by a pragma rather than a command.

We have a lot to learn about this yet and we do not want to paint ourselves
into a corner by commiting to specific syntax too early. (CVS 3921)

FossilOrigin-Name: b13e497a326697ab42b429993a1eee7df3c0c3eb
This commit is contained in:
drh
2007-05-04 18:30:40 +00:00
parent 744f2f4658
commit ca5557f91d
11 changed files with 123 additions and 82 deletions

View File

@@ -1,5 +1,5 @@
C Tighter\scompression\sof\sthe\skeyword\shash\stable.\s(CVS\s3920) C Change\sincremental\svacuum\sto\sbe\striggered\sby\sa\spragma\srather\sthan\sa\scommand.\nWe\shave\sa\slot\sto\slearn\sabout\sthis\syet\sand\swe\sdo\snot\swant\sto\spaint\sourselves\ninto\sa\scorner\sby\scommiting\sto\sspecific\ssyntax\stoo\searly.\s(CVS\s3921)
D 2007-05-04T17:07:53 D 2007-05-04T18:30:41
F Makefile.in 8cab54f7c9f5af8f22fd97ddf1ecfd1e1860de62 F Makefile.in 8cab54f7c9f5af8f22fd97ddf1ecfd1e1860de62
F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935 F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@@ -61,7 +61,7 @@ F src/attach.c f088f8155541ff75542239ec40cf05f3d81390ba
F src/auth.c 902f4722661c796b97f007d9606bd7529c02597f F src/auth.c 902f4722661c796b97f007d9606bd7529c02597f
F src/btree.c ebf16f19fc9e732c93b98083c4dfdbadad247e5c F src/btree.c ebf16f19fc9e732c93b98083c4dfdbadad247e5c
F src/btree.h 2c187d60cf76d74c2b4767294d6b5fa267037ff0 F src/btree.h 2c187d60cf76d74c2b4767294d6b5fa267037ff0
F src/build.c 470c3d39ab87bc817858493a32446630d6f553f3 F src/build.c 0dd6f0d0a5d304be91374f4c7228a3e9b00ff7f1
F src/callback.c 6414ed32d55859d0f65067aa5b88d2da27b3af9e F src/callback.c 6414ed32d55859d0f65067aa5b88d2da27b3af9e
F src/complete.c 7d1a44be8f37de125fcafd3d3a018690b3799675 F src/complete.c 7d1a44be8f37de125fcafd3d3a018690b3799675
F src/date.c c34a9c86ffd6da4cb3903ea038d977ec539d07e2 F src/date.c c34a9c86ffd6da4cb3903ea038d977ec539d07e2
@@ -89,8 +89,8 @@ F src/os_win.c 5e9e3d2aeed4d6f1b6ae81e866919f4f43b4a23d
F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b
F src/pager.c f01e0e577b7b54c3cdba24a30ecc585a805f23fa F src/pager.c f01e0e577b7b54c3cdba24a30ecc585a805f23fa
F src/pager.h d652ddf092d2318d00e41f8539760fe8e57c157c F src/pager.h d652ddf092d2318d00e41f8539760fe8e57c157c
F src/parse.y 502cec813c863f864cb951d95121dbabd56b9396 F src/parse.y a5bdc301e970ceb3826b56a84898b8966d5353f8
F src/pragma.c 4fdefc03c3fd0ee87f8aad82bf80ba9bf1cdf416 F src/pragma.c 3f16c1274bc25afb630b61a3630ea19a2fd0b5dc
F src/prepare.c 03277063bc4f5860efbf23548fa0123ac0f6eaec F src/prepare.c 03277063bc4f5860efbf23548fa0123ac0f6eaec
F src/printf.c 0c6f40648770831341ac45ab32423a80b4c87f05 F src/printf.c 0c6f40648770831341ac45ab32423a80b4c87f05
F src/random.c 6119474a6f6917f708c1dee25b9a8e519a620e88 F src/random.c 6119474a6f6917f708c1dee25b9a8e519a620e88
@@ -99,7 +99,7 @@ F src/server.c 087b92a39d883e3fa113cae259d64e4c7438bc96
F src/shell.c d07ae326b3815d80f71c69b3c7584382e47f6447 F src/shell.c d07ae326b3815d80f71c69b3c7584382e47f6447
F src/sqlite.h.in a666300976897eced975b448f722a722b362c6b1 F src/sqlite.h.in a666300976897eced975b448f722a722b362c6b1
F src/sqlite3ext.h 7d0d363ea7327e817ef0dfe1b7eee1f171b72890 F src/sqlite3ext.h 7d0d363ea7327e817ef0dfe1b7eee1f171b72890
F src/sqliteInt.h 478ca87a2a08b56db820e36935b134fd30da8d17 F src/sqliteInt.h 93ac1a9f1c8facfd861cf548845d2abc36039670
F src/table.c a8de75bcedf84d4060d804264b067ab3b1a3561d F src/table.c a8de75bcedf84d4060d804264b067ab3b1a3561d
F src/tclsqlite.c cd87bbaffd115ded71b4b9c03be7b5b213c4ba7a F src/tclsqlite.c cd87bbaffd115ded71b4b9c03be7b5b213c4ba7a
F src/test1.c 29a39fdde51f4612082ecf3f5af54dac93766f87 F src/test1.c 29a39fdde51f4612082ecf3f5af54dac93766f87
@@ -125,7 +125,7 @@ F src/update.c 3359041db390a8f856d67272f299600e2104f350
F src/utf.c e64a48bc21aa973eb622dd47da87d56a4cdcf528 F src/utf.c e64a48bc21aa973eb622dd47da87d56a4cdcf528
F src/util.c 9f9fec5dc7ffab8ff982508d03af37269a59ff91 F src/util.c 9f9fec5dc7ffab8ff982508d03af37269a59ff91
F src/vacuum.c 8bd895d29e7074e78d4e80f948e35ddc9cf2beef F src/vacuum.c 8bd895d29e7074e78d4e80f948e35ddc9cf2beef
F src/vdbe.c 74f348b125187f4bebd8bbba381e9be7de0a2bcf F src/vdbe.c 725a808e9bdc317aba963f33054db2dbebdfeecd
F src/vdbe.h 0025259af1939fb264a545816c69e4b5b8d52691 F src/vdbe.h 0025259af1939fb264a545816c69e4b5b8d52691
F src/vdbeInt.h cb02cbbceddf3b40d49012e9f41576f17bcbec97 F src/vdbeInt.h cb02cbbceddf3b40d49012e9f41576f17bcbec97
F src/vdbeapi.c 37d793559390bec8a00c556f651f21b5f9e589af F src/vdbeapi.c 37d793559390bec8a00c556f651f21b5f9e589af
@@ -244,9 +244,9 @@ F test/hook.test 7e7645fd9a033f79cce8fdff151e32715e7ec50a
F test/in.test 369cb2aa1eab02296b4ec470732fe8c131260b1d F test/in.test 369cb2aa1eab02296b4ec470732fe8c131260b1d
F test/incrblob.test ebfee15334f33dae682d3161acff9c4d169d4672 F test/incrblob.test ebfee15334f33dae682d3161acff9c4d169d4672
F test/incrblob_err.test 9f78c159279c992fa5ce49c06f50b680fc470520 F test/incrblob_err.test 9f78c159279c992fa5ce49c06f50b680fc470520
F test/incrvacuum.test 2173bc075c7b3b96ccf228d737dd4f5c29500dc4 F test/incrvacuum.test f490c8ae86f2ecca622425d02e27d3119058cb21
F test/incrvacuum2.test c8c33a6e2b7ddfaa7256ae84a776e22cce9c920e F test/incrvacuum2.test a1457ad2441e49e99fbc4d74f9575dd9f7ddbde3
F test/incrvacuum_ioerr.test 0ebc382bcc2036ec58cf49cc5ffada45f75d907b F test/incrvacuum_ioerr.test cb331403b8dea3c5bae6163861ff25037b0df56a
F test/index.test e65df12bed94b2903ee89987115e1578687e9266 F test/index.test e65df12bed94b2903ee89987115e1578687e9266
F test/index2.test ee83c6b5e3173a3d7137140d945d9a5d4fdfb9d6 F test/index2.test ee83c6b5e3173a3d7137140d945d9a5d4fdfb9d6
F test/index3.test f66718cd92ce1216819d47e6a156755e4b2c4ca1 F test/index3.test f66718cd92ce1216819d47e6a156755e4b2c4ca1
@@ -407,7 +407,7 @@ F tool/lempar.c 8f998bf8d08e2123149c2cc5d0597cd5d5d1abdd
F tool/memleak.awk 4e7690a51bf3ed757e611273d43fe3f65b510133 F tool/memleak.awk 4e7690a51bf3ed757e611273d43fe3f65b510133
F tool/memleak2.awk 9cc20c8e8f3c675efac71ea0721ee6874a1566e8 F tool/memleak2.awk 9cc20c8e8f3c675efac71ea0721ee6874a1566e8
F tool/memleak3.tcl 7707006ee908cffff210c98158788d85bb3fcdbf F tool/memleak3.tcl 7707006ee908cffff210c98158788d85bb3fcdbf
F tool/mkkeywordhash.c 39eb0ff0bc3faf8deea67b44fddcb64a29a27521 F tool/mkkeywordhash.c fe15d1cbc61c2b0375634b6d8c1ef24520799ea0
F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e x F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e x
F tool/mksqlite3c.tcl fa0429d32cb0756b23def531ec863bc0e216f375 F tool/mksqlite3c.tcl fa0429d32cb0756b23def531ec863bc0e216f375
F tool/mksqlite3internalh.tcl a85bb0c812db1a060e6e6dfab4e4c817f53d194b F tool/mksqlite3internalh.tcl a85bb0c812db1a060e6e6dfab4e4c817f53d194b
@@ -475,7 +475,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5 F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
P ed713f9ccb5d0f306a79ab9931e43db2327fb435 P 681216767d7fabfccb0b12f6a81b18b6d1c252bf
R 5a6e4b5dc3429e2f2a7bdff2ac75dece R 95c89ba898130ee0ba9ae5e0f60736ff
U drh U drh
Z 72fb146ed224d9e10bb3659cbe4d7ad5 Z f926a6c2de5eba8d75508bc0c0193258

View File

@@ -1 +1 @@
681216767d7fabfccb0b12f6a81b18b6d1c252bf b13e497a326697ab42b429993a1eee7df3c0c3eb

View File

@@ -22,7 +22,7 @@
** COMMIT ** COMMIT
** ROLLBACK ** 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 "sqliteInt.h"
#include <ctype.h> #include <ctype.h>
@@ -3351,26 +3351,3 @@ KeyInfo *sqlite3IndexKeyinfo(Parse *pParse, Index *pIdx){
} }
return pKey; 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 */

View File

@@ -14,7 +14,7 @@
** the parser. Lemon will also generate a header file containing ** the parser. Lemon will also generate a header file containing
** numeric codes for all of the tokens. ** 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_" // All token codes are small integers with #defines that begin with "TK_"
@@ -174,7 +174,7 @@ id(A) ::= ID(X). {A = X;}
%fallback ID %fallback ID
ABORT AFTER ANALYZE ASC ATTACH BEFORE BEGIN CASCADE CAST CONFLICT ABORT AFTER ANALYZE ASC ATTACH BEFORE BEGIN CASCADE CAST CONFLICT
DATABASE DEFERRED DESC DETACH EACH END EXCLUSIVE EXPLAIN FAIL FOR 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 QUERY KEY OF OFFSET PRAGMA RAISE REPLACE RESTRICT ROW
TEMP TRIGGER VACUUM VIEW VIRTUAL TEMP TRIGGER VACUUM VIEW VIRTUAL
%ifdef SQLITE_OMIT_COMPOUND_SELECT %ifdef SQLITE_OMIT_COMPOUND_SELECT
@@ -903,11 +903,6 @@ cmd ::= VACUUM nm. {sqlite3Vacuum(pParse);}
%endif SQLITE_OMIT_ATTACH %endif SQLITE_OMIT_ATTACH
%endif SQLITE_OMIT_VACUUM %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 ///////////////////////////// ///////////////////////////// The PRAGMA command /////////////////////////////
// //
%ifndef SQLITE_OMIT_PRAGMA %ifndef SQLITE_OMIT_PRAGMA

View File

@@ -11,7 +11,7 @@
************************************************************************* *************************************************************************
** This file contains code used to implement the PRAGMA command. ** 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 "sqliteInt.h"
#include "os.h" #include "os.h"
@@ -414,6 +414,27 @@ void sqlite3Pragma(
}else }else
#endif #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 #ifndef SQLITE_OMIT_PAGER_PRAGMAS
/* /*
** PRAGMA [database.]cache_size ** PRAGMA [database.]cache_size

View File

@@ -11,7 +11,7 @@
************************************************************************* *************************************************************************
** Internal interface definitions for SQLite. ** 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_ #ifndef _SQLITEINT_H_
#define _SQLITEINT_H_ #define _SQLITEINT_H_
@@ -1914,7 +1914,6 @@ int sqlite3VtabBegin(sqlite3 *, sqlite3_vtab *);
FuncDef *sqlite3VtabOverloadFunction(FuncDef*, int nArg, Expr*); FuncDef *sqlite3VtabOverloadFunction(FuncDef*, int nArg, Expr*);
void sqlite3InvalidFunction(sqlite3_context*,int,sqlite3_value**); void sqlite3InvalidFunction(sqlite3_context*,int,sqlite3_value**);
int sqlite3Reprepare(Vdbe*); int sqlite3Reprepare(Vdbe*);
void sqlite3IncrVacuum(Parse *pParse, Token*);
#ifdef SQLITE_SSE #ifdef SQLITE_SSE
#include "sseInt.h" #include "sseInt.h"

View File

@@ -43,7 +43,7 @@
** in this file for details. If in doubt, do not deviate from existing ** in this file for details. If in doubt, do not deviate from existing
** commenting and indentation practices when changing or adding code. ** 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 "sqliteInt.h"
#include "os.h" #include "os.h"
@@ -4600,14 +4600,17 @@ case OP_Vacuum: { /* no-push */
#endif #endif
#if !defined(SQLITE_OMIT_AUTOVACUUM) #if !defined(SQLITE_OMIT_AUTOVACUUM)
/* Opcode: IncrVacuum * P2 * /* Opcode: IncrVacuum P1 P2 *
** **
** Perform a single step of the incremental vacuum procedure on ** 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. ** P2. Otherwise, fall through to the next instruction.
*/ */
case OP_IncrVacuum: { /* no-push */ 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); rc = sqlite3BtreeIncrVacuum(pBt);
if( rc==SQLITE_DONE ){ if( rc==SQLITE_DONE ){
pc = pOp->p2 - 1; pc = pOp->p2 - 1;

View File

@@ -14,7 +14,7 @@
# Note: There are also some tests for incremental vacuum and IO # Note: There are also some tests for incremental vacuum and IO
# errors in incrvacuum_ioerr.test. # errors in incrvacuum_ioerr.test.
# #
# $Id: incrvacuum.test,v 1.5 2007/05/02 17:54:56 drh Exp $ # $Id: incrvacuum.test,v 1.6 2007/05/04 18:30:41 drh Exp $
set testdir [file dirname $argv0] set testdir [file dirname $argv0]
source $testdir/tester.tcl source $testdir/tester.tcl
@@ -155,7 +155,7 @@ do_test incrvacuum-3.4 {
#--------------------------------------------------------------------- #---------------------------------------------------------------------
# Try to run a very simple incremental vacuum. Also verify that # Try to run a very simple incremental vacuum. Also verify that
# INCREMENTAL VACUUM is a harmless no-op against a database that # PRAGMA incremental_vacuum is a harmless no-op against a database that
# does not support auto-vacuum. # does not support auto-vacuum.
# #
do_test incrvacuum-4.1 { do_test incrvacuum-4.1 {
@@ -176,7 +176,7 @@ do_test incrvacuum-4.2 {
} {5} } {5}
do_test incrvacuum-4.3 { do_test incrvacuum-4.3 {
set ::nStep 0 set ::nStep 0
db eval {INCREMENTAL VACUUM} { db eval {pragma incremental_vacuum(10)} {
incr ::nStep incr ::nStep
} }
list [expr {[file size test.db] / 1024}] $::nStep list [expr {[file size test.db] / 1024}] $::nStep
@@ -193,7 +193,7 @@ do_test incrvacuum-5.1.2 {
execsql { execsql {
BEGIN; BEGIN;
DROP TABLE tbl2; DROP TABLE tbl2;
INCREMENTAL VACUUM; PRAGMA incremental_vacuum;
COMMIT; COMMIT;
} }
expr {[file size test.db] / 1024} expr {[file size test.db] / 1024}
@@ -205,7 +205,7 @@ do_test incrvacuum-5.2.1 {
BEGIN; BEGIN;
CREATE TABLE tbl1(a); CREATE TABLE tbl1(a);
INSERT INTO tbl1 VALUES($::str); INSERT INTO tbl1 VALUES($::str);
INCREMENTAL VACUUM; -- this is a no-op. PRAGMA incremental_vacuum; -- this is a no-op.
COMMIT; COMMIT;
} }
expr {[file size test.db] / 1024} expr {[file size test.db] / 1024}
@@ -224,7 +224,7 @@ do_test incrvacuum-5.2.2 {
do_test incrvacuum-5.2.3 { do_test incrvacuum-5.2.3 {
execsql { execsql {
BEGIN; BEGIN;
INCREMENTAL VACUUM; -- Vacuum up the two pages. PRAGMA incremental_vacuum; -- Vacuum up the two pages.
CREATE TABLE tbl2(b); -- Use one free page as a table root. CREATE TABLE tbl2(b); -- Use one free page as a table root.
INSERT INTO tbl2 VALUES('a nice string'); INSERT INTO tbl2 VALUES('a nice string');
COMMIT; COMMIT;
@@ -240,7 +240,7 @@ do_test incrvacuum-5.2.5 {
execsql { execsql {
DROP TABLE tbl1; DROP TABLE tbl1;
DROP TABLE tbl2; DROP TABLE tbl2;
INCREMENTAL VACUUM; PRAGMA incremental_vacuum;
} }
expr {[file size test.db] / 1024} expr {[file size test.db] / 1024}
} {1} } {1}
@@ -265,22 +265,22 @@ set TestScriptList [list {
INSERT INTO t2 SELECT a, b FROM t1; INSERT INTO t2 SELECT a, b FROM t1;
INSERT INTO t1 SELECT b, a FROM t2; INSERT INTO t1 SELECT b, a FROM t2;
UPDATE t2 SET b = ''; UPDATE t2 SET b = '';
INCREMENTAL VACUUM; PRAGMA incremental_vacuum;
} { } {
UPDATE t2 SET b = (SELECT b FROM t1 WHERE t1.oid = t2.oid); UPDATE t2 SET b = (SELECT b FROM t1 WHERE t1.oid = t2.oid);
INCREMENTAL VACUUM; PRAGMA incremental_vacuum;
} { } {
CREATE TABLE t3(a, b); CREATE TABLE t3(a, b);
INSERT INTO t3 SELECT * FROM t2; INSERT INTO t3 SELECT * FROM t2;
DROP TABLE t2; DROP TABLE t2;
INCREMENTAL VACUUM; PRAGMA incremental_vacuum;
} { } {
CREATE INDEX t3_i ON t3(a); CREATE INDEX t3_i ON t3(a);
COMMIT; COMMIT;
} { } {
BEGIN; BEGIN;
DROP INDEX t3_i; DROP INDEX t3_i;
INCREMENTAL VACUUM; PRAGMA incremental_vacuum;
INSERT INTO t3 VALUES('hello', 'world'); INSERT INTO t3 VALUES('hello', 'world');
ROLLBACK; ROLLBACK;
} { } {
@@ -355,7 +355,7 @@ for {set jj 0} {$jj < 10} {incr jj} {
execsql { execsql {
DROP TABLE IF EXISTS tbl1; DROP TABLE IF EXISTS tbl1;
DROP TABLE IF EXISTS tbl2; DROP TABLE IF EXISTS tbl2;
INCREMENTAL VACUUM; PRAGMA incremental_vacuum;
CREATE TABLE tbl1(a, b); CREATE TABLE tbl1(a, b);
CREATE TABLE tbl2(a, b); CREATE TABLE tbl2(a, b);
BEGIN; BEGIN;
@@ -378,7 +378,7 @@ for {set jj 0} {$jj < 10} {incr jj} {
set ::nRow 0 set ::nRow 0
db eval {SELECT a FROM tbl2} {} { db eval {SELECT a FROM tbl2} {} {
if {$a == [expr $jj*100]} { if {$a == [expr $jj*100]} {
db eval {INCREMENTAL VACUUM} db eval {PRAGMA incremental_vacuum}
} }
incr ::nRow incr ::nRow
} }
@@ -396,7 +396,7 @@ while 1 {
execsql { execsql {
DROP TABLE IF EXISTS tbl1; DROP TABLE IF EXISTS tbl1;
DROP TABLE IF EXISTS tbl2; DROP TABLE IF EXISTS tbl2;
INCREMENTAL VACUUM; PRAGMA incremental_vacuum;
CREATE TABLE tbl1(a, b); CREATE TABLE tbl1(a, b);
CREATE TABLE tbl2(a, b); CREATE TABLE tbl2(a, b);
BEGIN; BEGIN;
@@ -414,7 +414,7 @@ while 1 {
do_test incrvacuum-7.${::iWrite}.2 { do_test incrvacuum-7.${::iWrite}.2 {
set ::nRow 0 set ::nRow 0
db eval {INCREMENTAL VACUUM} { db eval {PRAGMA incremental_vacuum} {
incr ::nRow incr ::nRow
if {$::nRow == $::iWrite} { if {$::nRow == $::iWrite} {
db eval { db eval {

View File

@@ -11,7 +11,7 @@
# This file implements regression tests for SQLite library. The # This file implements regression tests for SQLite library. The
# focus of this file is testing the incremental vacuum feature. # focus of this file is testing the incremental vacuum feature.
# #
# $Id: incrvacuum2.test,v 1.1 2007/05/04 16:14:39 drh Exp $ # $Id: incrvacuum2.test,v 1.2 2007/05/04 18:30:41 drh Exp $
set testdir [file dirname $argv0] set testdir [file dirname $argv0]
source $testdir/tester.tcl source $testdir/tester.tcl
@@ -41,7 +41,7 @@ do_test incrvacuum2-1.1 {
# #
do_test incrvacuum2-1.2 { do_test incrvacuum2-1.2 {
execsql { execsql {
INCREMENTAL VACUUM 1 PRAGMA incremental_vacuum(1);
} }
file size test.db file size test.db
} {31744} } {31744}
@@ -50,7 +50,7 @@ do_test incrvacuum2-1.2 {
# #
do_test incrvacuum2-1.3 { do_test incrvacuum2-1.3 {
execsql { execsql {
INCREMENTAL VACUUM 5 PRAGMA incremental_vacuum(5);
} }
file size test.db file size test.db
} {26624} } {26624}
@@ -59,9 +59,57 @@ do_test incrvacuum2-1.3 {
# #
do_test incrvacuum2-1.4 { do_test incrvacuum2-1.4 {
execsql { execsql {
INCREMENTAL VACUUM 1000 PRAGMA incremental_vacuum(1000);
} }
file size test.db file size test.db
} {3072} } {3072}
# Make sure incremental vacuum works on attached databases.
#
do_test incrvacuum2-2.1 {
file delete -force test2.db test2.db-journal
execsql {
ATTACH DATABASE 'test2.db' AS aux;
PRAGMA aux.auto_vacuum=incremental;
CREATE TABLE aux.t2(x);
INSERT INTO t2 VALUES(zeroblob(30000));
INSERT INTO t1 SELECT * FROM t2;
DELETE FROM t2;
DELETE FROM t1;
}
list [file size test.db] [file size test2.db]
} {32768 32768}
do_test incrvacuum2-2.2 {
execsql {
PRAGMA aux.incremental_vacuum(1)
}
list [file size test.db] [file size test2.db]
} {32768 31744}
do_test incrvacuum2-2.3 {
execsql {
PRAGMA aux.incremental_vacuum(5)
}
list [file size test.db] [file size test2.db]
} {32768 26624}
do_test incrvacuum2-2.4 {
execsql {
PRAGMA main.incremental_vacuum(5)
}
list [file size test.db] [file size test2.db]
} {27648 26624}
do_test incrvacuum2-2.5 {
execsql {
PRAGMA aux.incremental_vacuum
}
list [file size test.db] [file size test2.db]
} {27648 3072}
do_test incrvacuum2-2.6 {
execsql {
PRAGMA incremental_vacuum(1)
}
list [file size test.db] [file size test2.db]
} {26624 3072}
finish_test finish_test

View File

@@ -15,7 +15,7 @@
# The tests in this file use special facilities that are only # The tests in this file use special facilities that are only
# available in the SQLite test fixture. # available in the SQLite test fixture.
# #
# $Id: incrvacuum_ioerr.test,v 1.1 2007/04/28 15:47:45 danielk1977 Exp $ # $Id: incrvacuum_ioerr.test,v 1.2 2007/05/04 18:30:41 drh Exp $
set testdir [file dirname $argv0] set testdir [file dirname $argv0]
source $testdir/tester.tcl source $testdir/tester.tcl
@@ -35,7 +35,7 @@ do_ioerr_test incrvacuum-ioerr-1 -cksum 1 -sqlprep {
BEGIN; BEGIN;
CREATE TABLE abc2(a); CREATE TABLE abc2(a);
DELETE FROM abc; DELETE FROM abc;
INCREMENTAL VACUUM; PRAGMA incremental_vacuum;
COMMIT; COMMIT;
} }
@@ -74,17 +74,16 @@ do_ioerr_test incrvacuum-ioerr-2 -start 1 -cksum 1 -tclprep {
db eval COMMIT db eval COMMIT
} -sqlbody { } -sqlbody {
BEGIN; BEGIN;
INCREMENTAL VACUUM; PRAGMA incremental_vacuum;
DELETE FROM abc WHERE (oid%3)==0; DELETE FROM abc WHERE (oid%3)==0;
INCREMENTAL VACUUM; PRAGMA incremental_vacuum;
INSERT INTO abc SELECT a || '1234567890' FROM abc WHERE oid%2; INSERT INTO abc SELECT a || '1234567890' FROM abc WHERE oid%2;
INCREMENTAL VACUUM; PRAGMA incremental_vacuum;
CREATE INDEX abc_i ON abc(a); CREATE INDEX abc_i ON abc(a);
DELETE FROM abc WHERE (oid%2)==0; DELETE FROM abc WHERE (oid%2)==0;
INCREMENTAL VACUUM; PRAGMA incremental_vacuum;
DROP INDEX abc_i; DROP INDEX abc_i;
INCREMENTAL VACUUM; PRAGMA incremental_vacuum;
COMMIT; COMMIT;
} }
finish_test finish_test

View File

@@ -15,7 +15,7 @@ static const char zHdr[] =
"**\n" "**\n"
"** The code in this file has been automatically generated by\n" "** The code in this file has been automatically generated by\n"
"**\n" "**\n"
"** $Header: /home/drh/sqlite/trans/cvs/sqlite/sqlite/tool/mkkeywordhash.c,v 1.29 2007/05/04 17:07:53 drh Exp $\n" "** $Header: /home/drh/sqlite/trans/cvs/sqlite/sqlite/tool/mkkeywordhash.c,v 1.30 2007/05/04 18:30:41 drh Exp $\n"
"**\n" "**\n"
"** The code in this file implements a function that determines whether\n" "** The code in this file implements a function that determines whether\n"
"** or not a given identifier is really an SQL keyword. The same thing\n" "** or not a given identifier is really an SQL keyword. The same thing\n"
@@ -199,7 +199,6 @@ static Keyword aKeywordTable[] = {
{ "IGNORE", "TK_IGNORE", CONFLICT|TRIGGER }, { "IGNORE", "TK_IGNORE", CONFLICT|TRIGGER },
{ "IMMEDIATE", "TK_IMMEDIATE", ALWAYS }, { "IMMEDIATE", "TK_IMMEDIATE", ALWAYS },
{ "IN", "TK_IN", ALWAYS }, { "IN", "TK_IN", ALWAYS },
{ "INCREMENTAL", "TK_INCREMENTAL", AUTOVACUUM },
{ "INDEX", "TK_INDEX", ALWAYS }, { "INDEX", "TK_INDEX", ALWAYS },
{ "INITIALLY", "TK_INITIALLY", FKEY }, { "INITIALLY", "TK_INITIALLY", FKEY },
{ "INNER", "TK_JOIN_KW", ALWAYS }, { "INNER", "TK_JOIN_KW", ALWAYS },