Index: src/pager.c ================================================================== --- src/pager.c +++ src/pager.c @@ -16,11 +16,11 @@ ** is separate from the database file. The pager also implements file ** locking to prevent two processes from writing the same database ** file simultaneously, or one process from reading the database while ** another is writing. ** -** @(#) $Id: pager.c,v 1.176 2004/11/08 09:26:10 danielk1977 Exp $ +** @(#) $Id: pager.c,v 1.177 2004/11/10 15:27:38 danielk1977 Exp $ */ #include "sqliteInt.h" #include "os.h" #include "pager.h" #include @@ -3329,10 +3329,12 @@ if( pPgOld ){ assert( pPgOld->nRef==0 ); unlinkHashChain(pPager, pPgOld); pPgOld->dirty = 0; if( pPgOld->needSync ){ + assert( pPgOld->inJournal ); + pPg->inJournal = 1; pPg->needSync = 1; } } /* Change the page number for pPg and insert it into the new hash-chain. */ Index: src/sqliteInt.h ================================================================== --- src/sqliteInt.h +++ src/sqliteInt.h @@ -9,11 +9,11 @@ ** May you share freely, never taking more than you give. ** ************************************************************************* ** Internal interface definitions for SQLite. ** -** @(#) $Id: sqliteInt.h,v 1.336 2004/11/09 12:44:39 danielk1977 Exp $ +** @(#) $Id: sqliteInt.h,v 1.337 2004/11/10 15:27:38 danielk1977 Exp $ */ #ifndef _SQLITEINT_H_ #define _SQLITEINT_H_ /* @@ -104,10 +104,11 @@ /* #define SQLITE_OMIT_AUTHORIZATION 1 */ /* #define SQLITE_OMIT_INMEMORYDB 1 */ /* #define SQLITE_OMIT_VACUUM 1 */ /* #define SQLITE_OMIT_DATETIME_FUNCS 1 */ /* #define SQLITE_OMIT_PROGRESS_CALLBACK 1 */ +/* #define SQLITE_OMIT_AUTOVACUUM */ /* ** GCC does not define the offsetof() macro so we'll have to do it ** ourselves. */ Index: src/test1.c ================================================================== --- src/test1.c +++ src/test1.c @@ -11,11 +11,11 @@ ************************************************************************* ** Code for testing the printf() interface to SQLite. This code ** is not included in the SQLite library. It is used for automated ** testing of the SQLite library. ** -** $Id: test1.c,v 1.108 2004/11/05 23:46:15 drh Exp $ +** $Id: test1.c,v 1.109 2004/11/10 15:27:38 danielk1977 Exp $ */ #include "sqliteInt.h" #include "tcl.h" #include "os.h" #include @@ -2561,10 +2561,21 @@ #ifdef SQLITE_OMIT_REINDEX Tcl_SetVar2(interp, "sqlite_options", "reindex", "0", TCL_GLOBAL_ONLY); #else Tcl_SetVar2(interp, "sqlite_options", "reindex", "1", TCL_GLOBAL_ONLY); #endif + +#ifdef SQLITE_OMIT_AUTOVACUUM + Tcl_SetVar2(interp, "sqlite_options", "autovacuum", "0", TCL_GLOBAL_ONLY); +#else + Tcl_SetVar2(interp, "sqlite_options", "autovacuum", "1", TCL_GLOBAL_ONLY); +#if SQLITE_DEFAULT_AUTOVACUUM==0 + Tcl_SetVar2(interp,"sqlite_options","default_autovacuum","0",TCL_GLOBAL_ONLY); +#else + Tcl_SetVar2(interp,"sqlite_options","default_autovacuum","1",TCL_GLOBAL_ONLY); +#endif +#endif /* SQLITE_OMIT_AUTOVACUUM */ } /* ** Register commands with the TCL interpreter. */ Index: test/attach3.test ================================================================== --- test/attach3.test +++ test/attach3.test @@ -10,11 +10,11 @@ #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this script is testing the ATTACH and DETACH commands # and schema changes to attached databases. # -# $Id: attach3.test,v 1.12 2004/11/05 05:20:40 drh Exp $ +# $Id: attach3.test,v 1.13 2004/11/10 15:27:38 danielk1977 Exp $ # set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -53,11 +53,11 @@ } {} do_test attach3-1.4 { execsql { SELECT * FROM aux.sqlite_master WHERE name = 't3'; } -} {table t3 t3 4 {CREATE TABLE t3(e, f)}} +} "table t3 t3 [expr $AUTOVACUUM?5:4] {CREATE TABLE t3(e, f)}" do_test attach3-1.5 { execsql { INSERT INTO t3 VALUES(1, 2); SELECT * FROM t3; } @@ -76,11 +76,11 @@ } {} do_test attach3-2.3 { execsql { SELECT * FROM aux.sqlite_master WHERE name = 'i1'; } -} {index i1 t3 5 {CREATE INDEX i1 on t3(e)}} +} "index i1 t3 [expr $AUTOVACUUM?6:5] {CREATE INDEX i1 on t3(e)}" # Drop the index on the aux database table. do_test attach3-3.1 { execsql { DROP INDEX aux.i1; @@ -90,11 +90,11 @@ do_test attach3-3.2 { execsql { CREATE INDEX aux.i1 on t3(e); SELECT * FROM aux.sqlite_master WHERE name = 'i1'; } -} {index i1 t3 5 {CREATE INDEX i1 on t3(e)}} +} "index i1 t3 [expr $AUTOVACUUM?6:5] {CREATE INDEX i1 on t3(e)}" do_test attach3-3.3 { execsql { DROP INDEX i1; SELECT * FROM aux.sqlite_master WHERE name = 'i1'; } Index: test/autovacuum.test ================================================================== --- test/autovacuum.test +++ test/autovacuum.test @@ -9,14 +9,21 @@ # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is testing the SELECT statement. # -# $Id: autovacuum.test,v 1.10 2004/11/08 12:32:50 danielk1977 Exp $ +# $Id: autovacuum.test,v 1.11 2004/11/10 15:27:38 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl + +# If this build of the library does not support auto-vacuum, omit this +# whole file. +ifcapable {!autovacuum} { + finish_test + return +} # Return a string $len characters long. The returned string is $char repeated # over and over. For example, [make_str abc 8] returns "abcabcab". proc make_str {char len} { set str [string repeat $char. $len] @@ -456,27 +463,27 @@ file delete -force test.db sqlite3 db test.db execsql { PRAGMA auto_vacuum; } -} {0} +} $AUTOVACUUM do_test autovacuum-3.5 { execsql { CREATE TABLE av1(x); PRAGMA auto_vacuum; } -} {0} +} $AUTOVACUUM do_test autovacuum-3.6 { execsql { PRAGMA auto_vacuum = 1; PRAGMA auto_vacuum; } -} {0} +} $AUTOVACUUM do_test autovacuum-3.7 { execsql { DROP TABLE av1; } file_pages -} {2} +} [expr $AUTOVACUUM?1:2] finish_test Index: test/btree.test ================================================================== --- test/btree.test +++ test/btree.test @@ -9,15 +9,20 @@ # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this script is btree database backend # -# $Id: btree.test,v 1.32 2004/11/10 11:55:14 danielk1977 Exp $ +# $Id: btree.test,v 1.33 2004/11/10 15:27:38 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl + +ifcapable default_autovacuum { + finish_test + return +} # Basic functionality. Open and close a database. # do_test btree-1.1 { file delete -force test1.bt Index: test/enc2.test ================================================================== --- test/enc2.test +++ test/enc2.test @@ -11,11 +11,11 @@ # This file implements regression tests for SQLite library. The focus of # this file is testing the SQLite routines used for converting between the # various suported unicode encodings (UTF-8, UTF-16, UTF-16le and # UTF-16be). # -# $Id: enc2.test,v 1.17 2004/06/30 08:20:16 danielk1977 Exp $ +# $Id: enc2.test,v 1.18 2004/11/10 15:27:38 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # The rough organisation of tests in this file is: @@ -418,11 +418,11 @@ } {} do_test enc2-7.4 { execsql { SELECT * FROM sqlite_master; } -} {table abc abc 2 {CREATE TABLE abc(a, b, c)}} +} "table abc abc [expr $AUTOVACUUM?3:2] {CREATE TABLE abc(a, b, c)}" do_test enc2-7.5 { execsql { PRAGMA encoding; } } {UTF-8} Index: test/insert.test ================================================================== --- test/insert.test +++ test/insert.test @@ -9,11 +9,11 @@ # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is testing the INSERT statement. # -# $Id: insert.test,v 1.20 2004/11/07 13:01:50 drh Exp $ +# $Id: insert.test,v 1.21 2004/11/10 15:27:38 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Try to insert into a non-existant table. @@ -243,11 +243,11 @@ # # Update for v3 - the first table now begins on page 2 of each file, not 3. execsql { SELECT rootpage FROM sqlite_master WHERE name='test1'; } -} {2} +} [expr $AUTOVACUUM?3:2] do_test insert-5.5 { # Verify that "t4" begins on page 3. # # Update for v3 - the first table now begins on page 2 of each file, not 3. execsql { Index: test/interrupt.test ================================================================== --- test/interrupt.test +++ test/interrupt.test @@ -9,11 +9,11 @@ # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this script is the sqlite_interrupt() API. # -# $Id: interrupt.test,v 1.6 2004/11/04 04:42:28 drh Exp $ +# $Id: interrupt.test,v 1.7 2004/11/10 15:27:38 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -100,11 +100,11 @@ do_test interrupt-2.3 { execsql { SELECT md5sum(a || b) FROM t1; } } $cksum -ifcapable vacuum { +ifcapable vacuum&&!$AUTOVACUUM { do_test interrupt-2.4 { expr {$::origsize>[file size test.db]} } 1 } integrity_check interrupt-2.5 Index: test/lock2.test ================================================================== --- test/lock2.test +++ test/lock2.test @@ -9,11 +9,11 @@ # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this script is database locks between competing processes. # -# $Id: lock2.test,v 1.3 2004/07/22 15:02:26 drh Exp $ +# $Id: lock2.test,v 1.4 2004/11/10 15:27:38 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -142,18 +142,18 @@ } {0 {}} do_test lock2-1.9 { execsql { SELECT * FROM sqlite_master; } -} {table abc abc 2 {CREATE TABLE abc(a, b, c)}} +} "table abc abc [expr $AUTOVACUUM?3:2] {CREATE TABLE abc(a, b, c)}" do_test lock2-1.10 { testfixture $::tf1 { db eval { SELECT * FROM sqlite_master; } } -} {table abc abc 2 {CREATE TABLE abc(a, b, c)}} +} "table abc abc [expr $AUTOVACUUM?3:2] {CREATE TABLE abc(a, b, c)}" catch {testfixture $::tf1 {db close}} catch {close $::tf1} finish_test Index: test/pagesize.test ================================================================== --- test/pagesize.test +++ test/pagesize.test @@ -9,11 +9,11 @@ # #*********************************************************************** # This file implements regression tests for SQLite library. # This file implements tests for the page_size PRAGMA. # -# $Id: pagesize.test,v 1.7 2004/11/04 04:42:28 drh Exp $ +# $Id: pagesize.test,v 1.8 2004/11/10 15:27:38 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -85,11 +85,11 @@ PRAGMA page_size } } $PGSZ do_test pagesize-2.$PGSZ.3 { file size test.db - } [expr {$PGSZ*2}] + } [expr {$PGSZ*($AUTOVACUUM?3:2)}] ifcapable {vacuum} { do_test pagesize-2.$PGSZ.4 { execsql {VACUUM} } {} } Index: test/tester.tcl ================================================================== --- test/tester.tcl +++ test/tester.tcl @@ -9,11 +9,11 @@ # #*********************************************************************** # This file implements some common TCL routines used for regression # testing the SQLite library # -# $Id: tester.tcl,v 1.40 2004/11/03 13:59:06 drh Exp $ +# $Id: tester.tcl,v 1.41 2004/11/10 15:27:38 danielk1977 Exp $ # Make sure tclsqlite3 was compiled correctly. Abort now with an # error message if not. # if {[sqlite3 -tcl-uses-utf]} { @@ -239,9 +239,14 @@ # Evaluate a boolean expression of capabilities. If true, execute the # code. Omit the code if false. # proc ifcapable {expr code} { - regsub -all {[a-z]+} $expr {$::sqlite_options(&)} e2 + regsub -all {[a-z_]+} $expr {$::sqlite_options(&)} e2 if !($e2) return return -code [catch {uplevel 1 $code}] } + +# If the library is compiled with the SQLITE_DEFAULT_AUTOVACUUM macro set +# to non-zero, then set the global variable $AUTOVACUUM to 1. +set AUTOVACUUM $sqlite_options(default_autovacuum) + Index: test/vacuum.test ================================================================== --- test/vacuum.test +++ test/vacuum.test @@ -9,11 +9,11 @@ # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is testing the VACUUM statement. # -# $Id: vacuum.test,v 1.28 2004/11/04 04:42:28 drh Exp $ +# $Id: vacuum.test,v 1.29 2004/11/10 15:27:38 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # If the VACUUM statement is disabled in the current build, skip all @@ -20,10 +20,14 @@ # the tests in this file. # ifcapable {!vacuum} { finish_test return +} +if $AUTOVACUUM { + finish_test + return } set fcnt 1 proc cksum {{db db}} { set sql "SELECT name, type, sql FROM sqlite_master ORDER BY name, type"