Add the ability to change the autovacuum status of an existing database
by setting the auto_vacuum pragma then running the VACUUM command. (CVS 4592)
FossilOrigin-Name: bdfc19e838b369a8c5d5d23663fad690f55ba3d7
diff --git a/src/main.c b/src/main.c
index a5b4d36..515bd85 100644
--- a/src/main.c
+++ b/src/main.c
@@ -14,7 +14,7 @@
** other files are for internal use by SQLite and should not be
** accessed by users of the library.
**
-** $Id: main.c,v 1.407 2007/10/12 19:35:49 drh Exp $
+** $Id: main.c,v 1.408 2007/12/05 01:38:23 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@@ -965,6 +965,7 @@
db->magic = SQLITE_MAGIC_BUSY;
db->aDb = db->aDbStatic;
db->autoCommit = 1;
+ db->nextAutovac = -1;
db->flags |= SQLITE_ShortColNames
#if SQLITE_DEFAULT_FILE_FORMAT<4
| SQLITE_LegacyFileFmt
diff --git a/src/pragma.c b/src/pragma.c
index 8f50321..6a53c0c 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.150 2007/11/13 10:30:25 danielk1977 Exp $
+** $Id: pragma.c,v 1.151 2007/12/05 01:38:24 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@@ -440,6 +440,7 @@
returnSingleInt(pParse, "auto_vacuum", auto_vacuum);
}else{
int eAuto = getAutoVacuum(zRight);
+ db->nextAutovac = eAuto;
if( eAuto>=0 ){
/* Call SetAutoVacuum() to set initialize the internal auto and
** incr-vacuum flags. This is required in case this connection
diff --git a/src/sqliteInt.h b/src/sqliteInt.h
index 3dadec3..0576378 100644
--- a/src/sqliteInt.h
+++ b/src/sqliteInt.h
@@ -11,7 +11,7 @@
*************************************************************************
** Internal interface definitions for SQLite.
**
-** @(#) $Id: sqliteInt.h,v 1.622 2007/11/29 17:05:18 danielk1977 Exp $
+** @(#) $Id: sqliteInt.h,v 1.623 2007/12/05 01:38:24 drh Exp $
*/
#ifndef _SQLITEINT_H_
#define _SQLITEINT_H_
@@ -481,6 +481,7 @@
u8 autoCommit; /* The auto-commit flag. */
u8 temp_store; /* 1: file 2: memory 0: default */
u8 mallocFailed; /* True if we have seen a malloc failure */
+ char nextAutovac; /* Autovac setting after VACUUM if >=0 */
int nTable; /* Number of tables in the database */
CollSeq *pDfltColl; /* The default collating sequence (BINARY) */
i64 lastRowid; /* ROWID of most recent insert (see above) */
diff --git a/src/vacuum.c b/src/vacuum.c
index ab56abd..49e456c 100644
--- a/src/vacuum.c
+++ b/src/vacuum.c
@@ -14,7 +14,7 @@
** Most of the code in this file may be omitted by defining the
** SQLITE_OMIT_VACUUM macro.
**
-** $Id: vacuum.c,v 1.74 2007/10/20 20:58:57 drh Exp $
+** $Id: vacuum.c,v 1.75 2007/12/05 01:38:24 drh Exp $
*/
#include "sqliteInt.h"
#include "vdbeInt.h"
@@ -125,7 +125,8 @@
}
#ifndef SQLITE_OMIT_AUTOVACUUM
- sqlite3BtreeSetAutoVacuum(pTemp, sqlite3BtreeGetAutoVacuum(pMain));
+ sqlite3BtreeSetAutoVacuum(pTemp, db->nextAutovac>=0 ? db->nextAutovac :
+ sqlite3BtreeGetAutoVacuum(pMain));
#endif
/* Begin a transaction */