aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2004-09-05 00:33:43 +0000
committerdrh <drh@noemail.net>2004-09-05 00:33:43 +0000
commitf2a611c9889f1d2ac4ea22c2b33ed979c2bcd982 (patch)
tree0bb539c255dec05cae508291587e2af2b6ba7eb0 /src
parentad3e0105473f7b14e21b419023b60d40c6d445c5 (diff)
downloadsqlite-f2a611c9889f1d2ac4ea22c2b33ed979c2bcd982.tar.gz
sqlite-f2a611c9889f1d2ac4ea22c2b33ed979c2bcd982.zip
Make VACUUM work when the page size is different than the default 1024.
Ticket #890. (CVS 1939) FossilOrigin-Name: fa82becae7e41c47a6387061932f692c6f9f472e
Diffstat (limited to 'src')
-rw-r--r--src/btree.c6
-rw-r--r--src/vacuum.c14
2 files changed, 12 insertions, 8 deletions
diff --git a/src/btree.c b/src/btree.c
index 9470d6008..669ef1973 100644
--- a/src/btree.c
+++ b/src/btree.c
@@ -9,7 +9,7 @@
** May you share freely, never taking more than you give.
**
*************************************************************************
-** $Id: btree.c,v 1.187 2004/09/03 23:32:19 drh Exp $
+** $Id: btree.c,v 1.188 2004/09/05 00:33:43 drh Exp $
**
** This file implements a external (disk-based) database using BTrees.
** For a detailed discussion of BTrees, refer to
@@ -1145,7 +1145,7 @@ int sqlite3BtreeSetPageSize(Btree *pBt, int pageSize, int nReserve){
if( nReserve<0 ){
nReserve = pBt->pageSize - pBt->usableSize;
}
- if( pageSize>512 && pageSize<SQLITE_MAX_PAGE_SIZE ){
+ if( pageSize>=512 && pageSize<=SQLITE_MAX_PAGE_SIZE ){
pBt->pageSize = pageSize;
sqlite3pager_set_pagesize(pBt->pPager, pageSize);
}
@@ -1225,7 +1225,6 @@ static int lockBtree(Btree *pBt){
}
assert( pBt->maxLeaf + 23 <= MX_CELL_SIZE(pBt) );
pBt->pPage1 = pPage1;
- pBt->pageSizeFixed = 1;
return SQLITE_OK;
page1_init_failed:
@@ -1283,6 +1282,7 @@ static int newDatabase(Btree *pBt){
data[23] = pBt->minLeafFrac;
memset(&data[24], 0, 100-24);
zeroPage(pP1, PTF_INTKEY|PTF_LEAF|PTF_LEAFDATA );
+ pBt->pageSizeFixed = 1;
return SQLITE_OK;
}
diff --git a/src/vacuum.c b/src/vacuum.c
index 5602ed501..9141cfe8e 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.29 2004/09/02 15:27:42 drh Exp $
+** $Id: vacuum.c,v 1.30 2004/09/05 00:33:43 drh Exp $
*/
#include "sqliteInt.h"
#include "os.h"
@@ -98,6 +98,7 @@ int sqlite3RunVacuum(char **pzErrMsg, sqlite *db){
int nFilename; /* number of characters in zFilename[] */
char *zTemp = 0; /* a temporary file in same directory as zFilename */
int i; /* Loop counter */
+ Btree *pMain; /* The database being vacuumed */
Btree *pTemp;
char *zSql = 0;
@@ -111,7 +112,8 @@ int sqlite3RunVacuum(char **pzErrMsg, sqlite *db){
/* Get the full pathname of the database file and create a
** temporary filename in the same directory as the original file.
*/
- zFilename = sqlite3BtreeGetFilename(db->aDb[0].pBt);
+ pMain = db->aDb[0].pBt;
+ zFilename = sqlite3BtreeGetFilename(pMain);
assert( zFilename );
if( zFilename[0]=='\0' ){
/* The in-memory database. Do nothing. Return directly to avoid causing
@@ -150,7 +152,11 @@ int sqlite3RunVacuum(char **pzErrMsg, sqlite *db){
sqliteFree(zSql);
zSql = 0;
if( rc!=SQLITE_OK ) goto end_of_vacuum;
- execSql(db, "PRAGMA vacuum_db.synchronous = off;");
+ assert( strcmp(db->aDb[db->nDb-1].zName,"vacuum_db")==0 );
+ pTemp = db->aDb[db->nDb-1].pBt;
+ sqlite3BtreeSetPageSize(pTemp, sqlite3BtreeGetPageSize(pMain), 0);
+ assert( sqlite3BtreeGetPageSize(pTemp)==sqlite3BtreeGetPageSize(pMain) );
+ execSql(db, "PRAGMA vacuum_db.synchronous=OFF");
/* Begin a transaction */
rc = execSql(db, "BEGIN;");
@@ -206,9 +212,7 @@ int sqlite3RunVacuum(char **pzErrMsg, sqlite *db){
** opened for writing. This way, the SQL transaction used to create the
** temporary database never needs to be committed.
*/
- pTemp = db->aDb[db->nDb-1].pBt;
if( sqlite3BtreeIsInTrans(pTemp) ){
- Btree *pMain = db->aDb[0].pBt;
u32 meta;
assert( 0==sqlite3BtreeIsInTrans(pMain) );