-C Auto-vacuum\sbug:\sDon't\sset\smeta(3)\sto\sa\spointer-map\spage\snumber\swhen\sdeleting\sa\stable.\s(CVS\s2066)
-D 2004-11-05T12:58:25
+C Make\sauto-vacuum\sa\srun-time\soption\s(default\sdetermined\sby\sSQLITE_DEFAULT_AUTOVACUUM\smacro).\s(CVS\s2067)
+D 2004-11-05T15:45:10
F Makefile.in c4d2416860f472a1e3393714d0372074197565df
F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457
F README a01693e454a00cc117967e3f9fdab2d4d52e9bc1
F sqlite3.pc.in 985b9bf34192a549d7d370e0f0b6b34a4f61369a
F src/attach.c e49d09dad9f5f9fb10b4b0c1be5a70ae4c45e689
F src/auth.c 3b81f2a42f48a62c2c9c9b0eda31a157c681edea
-F src/btree.c 6a61345b550be1040b208c5191911676fd9fee72
-F src/btree.h 3166388fa58c5594d8064d38b43440d79da38fb6
+F src/btree.c 9ca965e9fbb28fb567cd76fe2a3cec1a161ad5ba
+F src/btree.h 861e40b759a195ba63819740e484390012cf81ab
F src/build.c dc8b9ab836f2323d9b313c2d703b00b2e9441382
F src/date.c 34bdb0082db7ec2a83ef00063f7b44e61ee19dad
F src/delete.c 6a54fd9f0fa6b93e13e40368a8b7206e3aae760c
F src/pager.c a43e2a392be51966129e9afb18b81551c9f222b8
F src/pager.h cbe4ba356d9dd3f30260f322b3dc77408164df14
F src/parse.y 97247c0a89ca1667729db5035f1ee60140960984
-F src/pragma.c 44e192eb5928157bdb015926f858a7c6e3ef6c98
+F src/pragma.c 6a0ae7721e614c5a921e918ab5206d5e654f1a6f
F src/printf.c 7a92adc00b758cd5ce087dae80181a8bbdb70ed2
F src/random.c eff68e3f257e05e81eae6c4d50a51eb88beb4ff3
F src/select.c 156990c636102bb6b8de85e7ff3396a62568476b
F test/attach2.test 399128a7b3b209a339a8dbf53ca2ed42eb982d1a
F test/attach3.test 287af46653e7435b2d1eda10d8115dcc8a6883e2
F test/auth.test 1cc252d9e7b3bdc1314199cbf3a0d3c5ed026c21
-F test/autovacuum.test 7878efa67268228299ed3759694bb43795b9ffa0
+F test/autovacuum.test e70d46d598aa4146a3069d830ec8002e384bebbc
F test/bigfile.test d3744a8821ce9abb8697f2826a3e3d22b719e89f
F test/bigrow.test f0aeb7573dcb8caaafea76454be3ade29b7fc747
F test/bind.test fa74f98417cd313f28272acff832a8a7d04a0916
F www/vdbe.tcl 59288db1ac5c0616296b26dce071c36cb611dfe9
F www/version3.tcl 092a01f5ef430d2c4acc0ae558d74c4bb89638a0
F www/whentouse.tcl fdacb0ba2d39831e8a6240d05a490026ad4c4e4c
-P 4e2433378e06210f0274c317c6d12b48236211fe
-R 26dd7f873a531a66e4d8d063a7f19d9e
+P 44a015b3a3bbecc4ec1e02bb371d3274e2b6edf3
+R fba5273e743f06f619fdf4a2b5c9b7df
U danielk1977
-Z 498d47c900b187710dd7df26608c1fd2
+Z 243e31232ec02903a39e127ae0fea404
-44a015b3a3bbecc4ec1e02bb371d3274e2b6edf3
\ No newline at end of file
+b9d5f007fc32d4f471e0e11cc4baadb100612878
\ No newline at end of file
** May you share freely, never taking more than you give.
**
*************************************************************************
-** $Id: btree.c,v 1.209 2004/11/05 12:58:25 danielk1977 Exp $
+** $Id: btree.c,v 1.210 2004/11/05 15:45:10 danielk1977 Exp $
**
** This file implements a external (disk-based) database using BTrees.
** For a detailed discussion of BTrees, refer to
pBt->maxEmbedFrac = 64; /* 25% */
pBt->minEmbedFrac = 32; /* 12.5% */
pBt->minLeafFrac = 32; /* 12.5% */
+ if( zFilename && strcmp(zFilename,":memory:") ){
+ pBt->autoVacuum = SQLITE_DEFAULT_AUTOVACUUM;
+ }
nReserve = 0;
}else{
nReserve = zDbHeader[20];
pBt->minEmbedFrac = zDbHeader[22];
pBt->minLeafFrac = zDbHeader[23];
pBt->pageSizeFixed = 1;
+#ifndef SQLITE_OMIT_AUTOVACUUM
+ pBt->autoVacuum = (get4byte(&zDbHeader[36 + 4*4])?1:0);
+#endif
}
pBt->usableSize = pBt->pageSize - nReserve;
pBt->psAligned = FORCE_ALIGNMENT(pBt->pageSize);
sqlite3pager_set_pagesize(pBt->pPager, pBt->pageSize);
*ppBtree = pBt;
-#ifdef SQLITE_AUTOVACUUM
- /* Note: This is temporary code for use during development of auto-vacuum. */
- if( zFilename && 0!=strcmp(zFilename, ":memory:") ){
- pBt->autoVacuum = 1;
- }
-#endif
return SQLITE_OK;
}
return pBt->pageSize - pBt->usableSize;
}
+/*
+** Change the 'auto-vacuum' property of the database. If the 'autoVacuum'
+** parameter is non-zero, then auto-vacuum mode is enabled. If zero, it
+** is disabled. The default value for the auto-vacuum property is
+** determined by the SQLITE_DEFAULT_AUTOVACUUM macro.
+*/
+int sqlite3BtreeSetAutoVacuum(Btree *pBt, int autoVacuum){
+#ifdef SQLITE_OMIT_AUTOVACUUM
+ return SQLITE_READONLY
+#else
+ if( pBt->pageSizeFixed ){
+ return SQLITE_READONLY;
+ }
+ pBt->autoVacuum = (autoVacuum?1:0);
+ return SQLITE_OK;
+#endif
+}
+
+/*
+** Return the value of the 'auto-vacuum' property. If auto-vacuum is
+** enabled 1 is returned. Otherwise 0.
+*/
+int sqlite3BtreeGetAutoVacuum(Btree *pBt){
+#ifdef SQLITE_OMIT_AUTOVACUUM
+ return 0;
+#else
+ return pBt->autoVacuum;
+#endif
+}
+
+
/*
** Get a reference to pPage1 of the database file. This will
** also acquire a readlock on that file.
** subsystem. See comments in the source code for a detailed description
** of what each interface routine does.
**
-** @(#) $Id: btree.h,v 1.59 2004/11/04 14:30:05 danielk1977 Exp $
+** @(#) $Id: btree.h,v 1.60 2004/11/05 15:45:10 danielk1977 Exp $
*/
#ifndef _BTREE_H_
#define _BTREE_H_
*/
#define SQLITE_N_BTREE_META 10
+/*
+** If defined as non-zero, auto-vacuum is enabled by default. Otherwise
+** it must be turned on for each database using "PRAGMA auto_vacuum = 1".
+*/
+#ifndef SQLITE_DEFAULT_AUTOVACUUM
+ #define SQLITE_DEFAULT_AUTOVACUUM 0
+#endif
+
/*
** Forward declarations of structure
*/
int sqlite3BtreeSetPageSize(Btree*,int,int);
int sqlite3BtreeGetPageSize(Btree*);
int sqlite3BtreeGetReserve(Btree*);
+int sqlite3BtreeSetAutoVacuum(Btree *, int);
+int sqlite3BtreeGetAutoVacuum(Btree *);
int sqlite3BtreeBeginTrans(Btree*,int);
int sqlite3BtreeCommit(Btree*);
int sqlite3BtreeRollback(Btree*);
*************************************************************************
** This file contains code used to implement the PRAGMA command.
**
-** $Id: pragma.c,v 1.73 2004/10/31 02:22:49 drh Exp $
+** $Id: pragma.c,v 1.74 2004/11/05 15:45:11 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
}
}else
+ /*
+ ** PRAGMA [database.]auto_vacuum
+ ** PRAGMA [database.]auto_vacuum=N
+ **
+ ** Get or set the (boolean) value of the database 'auto-vacuum' parameter.
+ */
+#ifndef SQLITE_OMIT_AUTOVACUUM
+ if( sqlite3StrICmp(zLeft,"auto_vacuum")==0 ){
+ Btree *pBt = pDb->pBt;
+ if( !zRight ){
+ int auto_vacuum =
+ pBt ? sqlite3BtreeGetAutoVacuum(pBt) : SQLITE_DEFAULT_AUTOVACUUM;
+ returnSingleInt(pParse, "auto_vacuum", auto_vacuum);
+ }else{
+ sqlite3BtreeSetAutoVacuum(pBt, getBoolean(zRight));
+ }
+ }else
+#endif
+
/*
** PRAGMA [database.]cache_size
** PRAGMA [database.]cache_size=N
# This file implements regression tests for SQLite library. The
# focus of this file is testing the SELECT statement.
#
-# $Id: autovacuum.test,v 1.8 2004/11/05 12:58:26 danielk1977 Exp $
+# $Id: autovacuum.test,v 1.9 2004/11/05 15:45:11 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
return [expr [file size test.db] / 1024]
}
+#-------------------------------------------------------------------------
# Test cases autovacuum-1.* work as follows:
#
# 1. A table with a single indexed field is created.
do_test autovacuum-1.1 {
execsql {
+ PRAGMA auto_vacuum = 1;
CREATE TABLE av1(a);
CREATE INDEX av1_idx ON av1(a);
}
} {4}
}
+#---------------------------------------------------------------------------
# Tests cases autovacuum-2.* test that root pages are allocated
# and deallocated correctly at the start of the file. Operation is roughly as
# follows:
file_pages
} 1
+#--------------------------------------------------------------------------
+# Test cases autovacuum-3.* test the operation of the "PRAGMA auto_vacuum"
+# command.
+#
+do_test autovacuum-3.1 {
+ execsql {
+ PRAGMA auto_vacuum;
+ }
+} {1}
+do_test autovacuum-3.2 {
+ db close
+ sqlite3 db test.db
+ execsql {
+ PRAGMA auto_vacuum;
+ }
+} {1}
+do_test autovacuum-3.3 {
+ execsql {
+ PRAGMA auto_vacuum = 0;
+ PRAGMA auto_vacuum;
+ }
+} {1}
+
+do_test autovacuum-3.4 {
+ db close
+ file delete -force test.db
+ sqlite3 db test.db
+ execsql {
+ PRAGMA auto_vacuum;
+ }
+} {0}
+do_test autovacuum-3.5 {
+ execsql {
+ CREATE TABLE av1(x);
+ PRAGMA auto_vacuum;
+ }
+} {0}
+do_test autovacuum-3.6 {
+ execsql {
+ PRAGMA auto_vacuum = 1;
+ PRAGMA auto_vacuum;
+ }
+} {0}
+do_test autovacuum-3.7 {
+ execsql {
+ DROP TABLE av1;
+ }
+ file_pages
+} {2}
+
finish_test