summaryrefslogtreecommitdiff
path: root/src/test_btree.c
diff options
context:
space:
mode:
authorHans-Christoph Steiner <hans@eds.org>2012-03-30 20:42:12 -0400
committerHans-Christoph Steiner <hans@eds.org>2012-03-30 20:42:12 -0400
commit7bb481fda9ecb134804b49c2ce77ca28f7eea583 (patch)
tree31b520b9914d3e2453968abe375f2c102772c3dc /src/test_btree.c
Imported Upstream version 2.0.3
Diffstat (limited to 'src/test_btree.c')
-rw-r--r--src/test_btree.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/src/test_btree.c b/src/test_btree.c
new file mode 100644
index 0000000..0048397
--- /dev/null
+++ b/src/test_btree.c
@@ -0,0 +1,62 @@
+/*
+** 2007 May 05
+**
+** The author disclaims copyright to this source code. In place of
+** a legal notice, here is a blessing:
+**
+** May you do good and not evil.
+** May you find forgiveness for yourself and forgive others.
+** May you share freely, never taking more than you give.
+**
+*************************************************************************
+** Code for testing the btree.c module in SQLite. This code
+** is not included in the SQLite library. It is used for automated
+** testing of the SQLite library.
+*/
+#include "btreeInt.h"
+#include <tcl.h>
+
+/*
+** Usage: sqlite3_shared_cache_report
+**
+** Return a list of file that are shared and the number of
+** references to each file.
+*/
+int sqlite3BtreeSharedCacheReport(
+ void * clientData,
+ Tcl_Interp *interp,
+ int objc,
+ Tcl_Obj *CONST objv[]
+){
+#ifndef SQLITE_OMIT_SHARED_CACHE
+ extern BtShared *sqlite3SharedCacheList;
+ BtShared *pBt;
+ Tcl_Obj *pRet = Tcl_NewObj();
+ for(pBt=GLOBAL(BtShared*,sqlite3SharedCacheList); pBt; pBt=pBt->pNext){
+ const char *zFile = sqlite3PagerFilename(pBt->pPager);
+ Tcl_ListObjAppendElement(interp, pRet, Tcl_NewStringObj(zFile, -1));
+ Tcl_ListObjAppendElement(interp, pRet, Tcl_NewIntObj(pBt->nRef));
+ }
+ Tcl_SetObjResult(interp, pRet);
+#endif
+ return TCL_OK;
+}
+
+/*
+** Print debugging information about all cursors to standard output.
+*/
+void sqlite3BtreeCursorList(Btree *p){
+#ifdef SQLITE_DEBUG
+ BtCursor *pCur;
+ BtShared *pBt = p->pBt;
+ for(pCur=pBt->pCursor; pCur; pCur=pCur->pNext){
+ MemPage *pPage = pCur->apPage[pCur->iPage];
+ char *zMode = pCur->wrFlag ? "rw" : "ro";
+ sqlite3DebugPrintf("CURSOR %p rooted at %4d(%s) currently at %d.%d%s\n",
+ pCur, pCur->pgnoRoot, zMode,
+ pPage ? pPage->pgno : 0, pCur->aiIdx[pCur->iPage],
+ (pCur->eState==CURSOR_VALID) ? "" : " eof"
+ );
+ }
+#endif
+}