aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/btree.c4
-rw-r--r--src/pager.c10
-rw-r--r--src/test3.c46
-rw-r--r--src/vacuum.c6
4 files changed, 59 insertions, 7 deletions
diff --git a/src/btree.c b/src/btree.c
index 71185701d..30db93f0b 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.226 2005/01/07 08:56:44 danielk1977 Exp $
+** $Id: btree.c,v 1.227 2005/01/08 12:42:39 danielk1977 Exp $
**
** This file implements a external (disk-based) database using BTrees.
** For a detailed discussion of BTrees, refer to
@@ -4487,6 +4487,7 @@ int sqlite3BtreeCreateTable(Btree *pBt, int *piTable, int flags){
pRoot = pPageMove;
}
+ /* Update the pointer-map and meta-data with the new root-page number. */
rc = ptrmapPut(pBt, pgnoRoot, PTRMAP_ROOTPAGE, 0);
if( rc ){
releasePage(pRoot);
@@ -4497,6 +4498,7 @@ int sqlite3BtreeCreateTable(Btree *pBt, int *piTable, int flags){
releasePage(pRoot);
return rc;
}
+
}else{
rc = allocatePage(pBt, &pRoot, &pgnoRoot, 1, 0);
if( rc ) return rc;
diff --git a/src/pager.c b/src/pager.c
index 22e3ec39c..c59e3a8de 100644
--- a/src/pager.c
+++ b/src/pager.c
@@ -18,7 +18,7 @@
** file simultaneously, or one process from reading the database while
** another is writing.
**
-** @(#) $Id: pager.c,v 1.179 2004/11/24 01:16:43 drh Exp $
+** @(#) $Id: pager.c,v 1.180 2005/01/08 12:42:39 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include "os.h"
@@ -244,6 +244,7 @@ struct Pager {
int nRef; /* Number of in-memory pages with PgHdr.nRef>0 */
int mxPage; /* Maximum number of pages to hold in cache */
int nHit, nMiss, nOvfl; /* Cache hits, missing, and LRU overflows */
+ int nRead,nWrite; /* Database pages read/written */
void (*xCodec)(void*,void*,Pgno,int); /* Routine for en/decoding data */
void *pCodecArg; /* First argument to xCodec() */
u8 journalOpen; /* True if journal file descriptors is valid */
@@ -2067,6 +2068,7 @@ static int pager_write_pagelist(PgHdr *pList){
TRACE3("STORE %d page %d\n", PAGERID(pPager), pList->pgno);
rc = sqlite3OsWrite(&pPager->fd, PGHDR_TO_DATA(pList), pPager->pageSize);
CODEC(pPager, PGHDR_TO_DATA(pList), pList->pgno, 0);
+ pPager->nWrite++;
}
#ifndef NDEBUG
else{
@@ -2350,6 +2352,8 @@ int sqlite3pager_get(Pager *pPager, Pgno pgno, void **ppPage){
}else{
memset(PGHDR_TO_DATA(pPg), 0, pPager->pageSize);
}
+ }else{
+ pPager->nRead++;
}
}
}else{
@@ -3006,7 +3010,7 @@ int sqlite3pager_isreadonly(Pager *pPager){
** This routine is used for testing and analysis only.
*/
int *sqlite3pager_stats(Pager *pPager){
- static int a[9];
+ static int a[11];
a[0] = pPager->nRef;
a[1] = pPager->nPage;
a[2] = pPager->mxPage;
@@ -3016,6 +3020,8 @@ int *sqlite3pager_stats(Pager *pPager){
a[6] = pPager->nHit;
a[7] = pPager->nMiss;
a[8] = pPager->nOvfl;
+ a[9] = pPager->nRead;
+ a[10] = pPager->nWrite;
return a;
}
diff --git a/src/test3.c b/src/test3.c
index 0ffcf9326..2e9b7fe95 100644
--- a/src/test3.c
+++ b/src/test3.c
@@ -13,7 +13,7 @@
** is not included in the SQLite library. It is used for automated
** testing of the SQLite library.
**
-** $Id: test3.c,v 1.57 2004/11/10 11:55:12 danielk1977 Exp $
+** $Id: test3.c,v 1.58 2005/01/08 12:42:39 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include "pager.h"
@@ -514,10 +514,10 @@ static int btree_pager_stats(
}
pBt = sqlite3TextToPtr(argv[1]);
a = sqlite3pager_stats(sqlite3BtreePager(pBt));
- for(i=0; i<9; i++){
+ for(i=0; i<11; i++){
static char *zName[] = {
"ref", "page", "max", "size", "state", "err",
- "hit", "miss", "ovfl",
+ "hit", "miss", "ovfl", "read", "write"
};
char zBuf[100];
Tcl_AppendElement(interp, zName[i]);
@@ -1321,6 +1321,45 @@ static int btree_varint_test(
}
/*
+** usage: btree_from_db DB-HANDLE
+**
+** This command returns the btree handle for the main database associated
+** with the database-handle passed as the argument. Example usage:
+**
+** sqlite3 db test.db
+** set bt [btree_from_db db]
+*/
+static int btree_from_db(
+ void *NotUsed,
+ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
+ int argc, /* Number of arguments */
+ const char **argv /* Text of each argument */
+){
+ char zBuf[100];
+ Tcl_CmdInfo info;
+ sqlite3 *db;
+ Btree *pBt;
+
+ if( argc!=2 ){
+ Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
+ " DB-HANDLE\"", 0);
+ return TCL_ERROR;
+ }
+
+ if( 1!=Tcl_GetCommandInfo(interp, argv[1], &info) ){
+ Tcl_AppendResult(interp, "No such db-handle: \"", argv[1], "\"", 0);
+ return TCL_ERROR;
+ }
+ db = *((sqlite3 **)info.objClientData);
+ assert( db );
+
+ pBt = db->aDb[0].pBt;
+ sqlite3_snprintf(sizeof(zBuf), zBuf, "%p", pBt);
+ Tcl_SetResult(interp, zBuf, TCL_VOLATILE);
+ return TCL_OK;
+}
+
+/*
** Register commands with the TCL interpreter.
*/
int Sqlitetest3_Init(Tcl_Interp *interp){
@@ -1366,6 +1405,7 @@ int Sqlitetest3_Init(Tcl_Interp *interp){
{ "btree_begin_statement", (Tcl_CmdProc*)btree_begin_statement },
{ "btree_commit_statement", (Tcl_CmdProc*)btree_commit_statement },
{ "btree_rollback_statement", (Tcl_CmdProc*)btree_rollback_statement },
+ { "btree_from_db", (Tcl_CmdProc*)btree_from_db },
};
int i;
diff --git a/src/vacuum.c b/src/vacuum.c
index 62fabfb4b..9531fc72c 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.35 2004/11/22 13:35:41 danielk1977 Exp $
+** $Id: vacuum.c,v 1.36 2005/01/08 12:42:40 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include "os.h"
@@ -166,6 +166,10 @@ int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db){
assert( sqlite3BtreeGetPageSize(pTemp)==sqlite3BtreeGetPageSize(pMain) );
execSql(db, "PRAGMA vacuum_db.synchronous=OFF");
+#ifndef SQLITE_OMIT_AUTOVACUUM
+ sqlite3BtreeSetAutoVacuum(pTemp, sqlite3BtreeGetAutoVacuum(pMain));
+#endif
+
/* Begin a transaction */
rc = execSql(db, "BEGIN;");
if( rc!=SQLITE_OK ) goto end_of_vacuum;