Index: src/btree.c ================================================================== --- src/btree.c +++ src/btree.c @@ -7,11 +7,11 @@ ** 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. ** ************************************************************************* -** $Id: btree.c,v 1.403 2007/08/20 22:48:42 drh Exp $ +** $Id: btree.c,v 1.404 2007/08/20 23:50:25 drh Exp $ ** ** This file implements a external (disk-based) database using BTrees. ** See the header comment on "btreeInt.h" for additional information. ** Including a description of file format and an overview of operation. */ @@ -1048,13 +1048,13 @@ */ static void pageDestructor(DbPage *pData, int pageSize){ MemPage *pPage; assert( (pageSize & 7)==0 ); pPage = (MemPage *)sqlite3PagerGetExtra(pData); - assert( sqlite3_mutex_held(pPage->pBt->mutex) ); if( pPage->pParent ){ MemPage *pParent = pPage->pParent; + assert( sqlite3_mutex_held(pPage->pBt->mutex) ); pPage->pParent = 0; releasePage(pParent); } pPage->isInit = 0; } @@ -1069,12 +1069,12 @@ */ static void pageReinit(DbPage *pData, int pageSize){ MemPage *pPage; assert( (pageSize & 7)==0 ); pPage = (MemPage *)sqlite3PagerGetExtra(pData); - assert( sqlite3_mutex_held(pPage->pBt->mutex) ); if( pPage->isInit ){ + assert( sqlite3_mutex_held(pPage->pBt->mutex) ); pPage->isInit = 0; sqlite3BtreeInitPage(pPage, pPage->pParent); } } Index: src/test3.c ================================================================== --- src/test3.c +++ src/test3.c @@ -11,11 +11,11 @@ ************************************************************************* ** 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. ** -** $Id: test3.c,v 1.78 2007/08/16 11:36:15 danielk1977 Exp $ +** $Id: test3.c,v 1.79 2007/08/20 23:50:25 drh Exp $ */ #include "sqliteInt.h" #include "pager.h" #include "btree.h" #include "tcl.h" @@ -46,10 +46,17 @@ default: zName = "SQLITE_Unknown"; break; } return zName; } +/* +** A bogus sqlite3 connection structure for use in the btree +** tests. +*/ +static sqlite3 sDb; +static int nRefSqlite3 = 0; + /* ** Usage: btree_open FILENAME NCACHE FLAGS ** ** Open a new database */ @@ -67,11 +74,16 @@ " FILENAME NCACHE FLAGS\"", 0); return TCL_ERROR; } if( Tcl_GetInt(interp, argv[2], &nCache) ) return TCL_ERROR; if( Tcl_GetInt(interp, argv[3], &flags) ) return TCL_ERROR; - rc = sqlite3BtreeOpen(argv[1], 0, &pBt, flags); + nRefSqlite3++; + if( nRefSqlite3==1 ){ + sDb.pVfs = sqlite3_vfs_find(0); + sDb.mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_RECURSIVE); + } + rc = sqlite3BtreeOpen(argv[1], &sDb, &pBt, flags); if( rc!=SQLITE_OK ){ Tcl_AppendResult(interp, errorName(rc), 0); return TCL_ERROR; } sqlite3BtreeSetCacheSize(pBt, nCache); @@ -102,10 +114,17 @@ rc = sqlite3BtreeClose(pBt); if( rc!=SQLITE_OK ){ Tcl_AppendResult(interp, errorName(rc), 0); return TCL_ERROR; } + nRefSqlite3--; + if( nRefSqlite3==0 ){ + sqlite3_mutex_free(sDb.mutex); + sDb.mutex = 0; + sqlite3_vfs_release(sDb.pVfs); + sDb.pVfs = 0; + } return TCL_OK; } /* ** Usage: btree_begin_transaction ID Index: src/test_config.c ================================================================== --- src/test_config.c +++ src/test_config.c @@ -14,11 +14,11 @@ ** None of the code in this file goes into a deliverable build. ** ** The focus of this file is providing the TCL testing layer ** access to compile-time constants. ** -** $Id: test_config.c,v 1.9 2007/08/20 22:48:43 drh Exp $ +** $Id: test_config.c,v 1.10 2007/08/20 23:50:25 drh Exp $ */ #include "sqliteInt.h" #include "tcl.h" #include "os.h" #include @@ -194,10 +194,16 @@ #ifdef SQLITE_ENABLE_FTS2 Tcl_SetVar2(interp, "sqlite_options", "fts2", "1", TCL_GLOBAL_ONLY); #else Tcl_SetVar2(interp, "sqlite_options", "fts2", "0", TCL_GLOBAL_ONLY); #endif + +#ifdef SQLITE_ENABLE_FTS3 + Tcl_SetVar2(interp, "sqlite_options", "fts3", "1", TCL_GLOBAL_ONLY); +#else + Tcl_SetVar2(interp, "sqlite_options", "fts3", "0", TCL_GLOBAL_ONLY); +#endif #ifdef SQLITE_OMIT_GLOBALRECOVER Tcl_SetVar2(interp, "sqlite_options", "globalrecover", "0", TCL_GLOBAL_ONLY); #else Tcl_SetVar2(interp, "sqlite_options", "globalrecover", "1", TCL_GLOBAL_ONLY);