-C The\sreplace()\sfunction\sshould\sreturn\sNULL\sif\sthe\ssecond\sargument\sis\san\nempty\sstring.\s\sTicket\s#2324.\s(CVS\s3877)
-D 2007-04-27T01:18:03
+C Modifications\sto\sbtree\sintegrity\scheck\sso\sthat\sit\scan\sbe\srun\sinside\sa\stransaction\safter\san\sincr\svacuum.\s(CVS\s3878)
+D 2007-04-27T07:05:44
F Makefile.in 8cab54f7c9f5af8f22fd97ddf1ecfd1e1860de62
F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
F src/analyze.c 4bbf5ddf9680587c6d4917e02e378b6037be3651
F src/attach.c a16ada4a4654a0d126b8223ec9494ebb81bc5c3c
F src/auth.c 902f4722661c796b97f007d9606bd7529c02597f
-F src/btree.c d08db3a8207bf884bd891829cab84c5e4cf18d99
+F src/btree.c 1e9261de4b663992604f089e6dbad6807e140b84
F src/btree.h 4c0b5855cef3e4e6627358aa69541d21a2015947
F src/build.c 02e01ec7907c7d947ab3041fda0e81eaed05db42
F src/callback.c 6414ed32d55859d0f65067aa5b88d2da27b3af9e
F test/func.test d66c42af501a77bd9b36c3d675d844b04db04765
F test/hook.test 7e7645fd9a033f79cce8fdff151e32715e7ec50a
F test/in.test 369cb2aa1eab02296b4ec470732fe8c131260b1d
-F test/incrvacuum.test ee05edff95770f211fab28132291c175cd282e0c
+F test/incrvacuum.test 6c14f0492f00437ebf8275eac0a80f97799d99d4
F test/index.test e65df12bed94b2903ee89987115e1578687e9266
F test/index2.test ee83c6b5e3173a3d7137140d945d9a5d4fdfb9d6
F test/index3.test f66718cd92ce1216819d47e6a156755e4b2c4ca1
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
-P f6a6d2b8872c05089810b1e095f39011f3035408
-R 6f143466ef3a026d3b533ab40fb9e7d5
-U drh
-Z 760fc2fbeee76e7c0e692c114576d572
+P e6a0c90dd9b4f7efe2153dd0c899b6e3d9846bd8
+R 3e1e2e05e5e9e264674bc6629d08b7ad
+U danielk1977
+Z 1d29f050695ac44aa0f3dcac643e125b
** May you share freely, never taking more than you give.
**
*************************************************************************
-** $Id: btree.c,v 1.359 2007/04/26 14:42:35 danielk1977 Exp $
+** $Id: btree.c,v 1.360 2007/04/27 07:05:44 danielk1977 Exp $
**
** This file implements a external (disk-based) database using BTrees.
** For a detailed discussion of BTrees, refer to
int nRef = sqlite3PagerRefcount(pPager);
#endif
- if( PTRMAP_ISPAGE(pBt, sqlite3PagerPagecount(pPager)) ){
- return SQLITE_CORRUPT_BKPT;
- }
-
assert(pBt->autoVacuum);
if( !pBt->incrVacuum ){
Pgno nFin = 0;
+
+
if( pBt->nTrunc==0 ){
Pgno nFree;
Pgno nPtrmap;
const int pgsz = pBt->pageSize;
Pgno nOrig = sqlite3PagerPagecount(pBt->pPager);
+
+ if( PTRMAP_ISPAGE(pBt, nOrig) ){
+ return SQLITE_CORRUPT_BKPT;
+ }
if( nOrig==PENDING_BYTE_PAGE(pBt) ){
nOrig--;
}
sCheck.mxErr = mxErr;
sCheck.nErr = 0;
*pnErr = 0;
+#ifndef SQLITE_OMIT_AUTOVACUUM
+ if( pBt->nTrunc!=0 ){
+ sCheck.nPage = pBt->nTrunc;
+ }
+#endif
if( sCheck.nPage==0 ){
unlockBtreeIfUnused(pBt);
return 0;
# This file implements regression tests for SQLite library. The
# focus of this file is testing the incremental vacuum feature.
#
-# $Id: incrvacuum.test,v 1.1 2007/04/26 14:42:36 danielk1977 Exp $
+# $Id: incrvacuum.test,v 1.2 2007/04/27 07:05:44 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
} {3}
#---------------------------------------------------------------------
-# Try to run a simple incremental vacuum.
+# Try to run a very simple incremental vacuum. Also verify that
+# INCREMENTAL VACUUM is a harmless no-op against a database that
+# does not support auto-vacuum.
#
do_test incrvacuum-4.1 {
set ::str [string repeat 1234567890 110]
list [expr {[file size test.db] / 1024}] $::nStep
} {3 2}
+#---------------------------------------------------------------------
+# The following tests - incrvacuum-5.* - test incremental vacuum
+# from within a transaction.
+#
+do_test incrvacuum-5.1.1 {
+ expr {[file size test.db] / 1024}
+} {3}
+do_test incrvacuum-5.1.2 {
+ execsql {
+ BEGIN;
+ DROP TABLE tbl2;
+ INCREMENTAL VACUUM;
+ COMMIT;
+ }
+ expr {[file size test.db] / 1024}
+} {1}
+
+do_test incrvacuum-5.2.1 {
+ set ::str [string repeat abcdefghij 110]
+ execsql {
+ BEGIN;
+ CREATE TABLE tbl1(a);
+ INSERT INTO tbl1 VALUES($::str);
+ INCREMENTAL VACUUM; -- this is a no-op.
+ COMMIT;
+ }
+ expr {[file size test.db] / 1024}
+} {4}
+do_test incrvacuum-5.2.2 {
+ set ::str [string repeat abcdefghij 110]
+ execsql {
+ BEGIN;
+ INSERT INTO tbl1 VALUES($::str);
+ INSERT INTO tbl1 SELECT * FROM tbl1;
+ DELETE FROM tbl1 WHERE oid%2; -- Put 2 overflow pages on free-list.
+ COMMIT;
+ }
+ expr {[file size test.db] / 1024}
+} {7}
+do_test incrvacuum-5.2.3 {
+ execsql {
+ BEGIN;
+ INCREMENTAL VACUUM; -- Vacuum up the two pages.
+ CREATE TABLE tbl2(b); -- Use one free page as a table root.
+ INSERT INTO tbl2 VALUES('a nice string');
+ COMMIT;
+ }
+ expr {[file size test.db] / 1024}
+} {6}
+do_test incrvacuum-5.2.4 {
+ execsql {
+ SELECT * FROM tbl2;
+ }
+} {{a nice string}}
+
+set TestScriptList [list {
+ BEGIN;
+ CREATE TABLE t1(a, b);
+ CREATE TABLE t2(a, b);
+ CREATE INDEX t1_i ON t1(a);
+ CREATE INDEX t2_i ON t2(a);
+} {
+ INSERT INTO t1 VALUES($::str1, $::str2);
+ INSERT INTO t1 VALUES($::str1||$::str2, $::str2||$::str1);
+ INSERT INTO t2 SELECT b, a FROM t1;
+ INSERT INTO t2 SELECT a, b FROM t1;
+ INSERT INTO t1 SELECT b, a FROM t2;
+ UPDATE t2 SET b = '';
+ INCREMENTAL VACUUM;
+} {
+ UPDATE t2 SET b = (SELECT b FROM t1 WHERE t1.oid = t2.oid);
+ INCREMENTAL VACUUM;
+} {
+ CREATE TABLE t3(a, b);
+ INSERT INTO t3 SELECT * FROM t2;
+ DROP TABLE t2;
+ INCREMENTAL VACUUM;
+} {
+ CREATE INDEX t3_i ON t3(a);
+ COMMIT;
+}]
+
+file delete -force test1.db test1.db-journal
+file delete -force test2.db test2.db-journal
+
+
+proc compare_dbs {A B tname} {
+ set tbl_list [execsql {
+ SELECT tbl_name FROM sqlite_master WHERE type = 'table'
+ } $A]
+
+ do_test ${tname}.1 [subst {
+ execsql {
+ SELECT tbl_name FROM sqlite_master WHERE type = 'table'
+ } $B
+ }] $tbl_list
+
+ set tn 1
+ foreach tbl $tbl_list {
+ set control [execsql "SELECT * FROM $tbl" $A]
+ do_test ${tname}.[incr tn] [subst {
+ execsql "SELECT * FROM $tbl" $B
+ }] $control
+ }
+}
+
+set ::str1 [string repeat abcdefghij 130]
+set ::str2 [string repeat 1234567890 105]
+sqlite3 db1 test1.db
+sqlite3 db2 test2.db
+execsql { PRAGMA auto_vacuum = 'none' } db1
+execsql { PRAGMA auto_vacuum = 'incremental' } db2
+
+set tn 1
+foreach sql $::TestScriptList {
+ execsql $sql db1
+ execsql $sql db2
+
+ compare_dbs db1 db2 incrvacuum-5.3.${tn}
+ do_test incrvacuum-5.3.${tn}.integrity {
+ execsql {
+ PRAGMA integrity_check;
+ } db2
+ } {ok}
+ incr tn
+}
+
+
+db1 close
+db2 close
+
+
+#---------------------------------------------------------------------
+# TODO: The following tests - incrvacuum-6.* - test that rolling back
+# a transaction that contains an incremental vacuum operation
+# works Ok.
+#
+
finish_test