-C Reenable\sthe\smemory\smanagement\slogic.\s\sThe\squick.test\sscript\snow\sruns\swith\nSQLITE_MEMDEBUG\sand\sSQLITE_ENABLE_MEMORY_MANAGEMENT.\s7\sminor\serrors.\s(CVS\s4265)
-D 2007-08-22T00:39:20
+C A\scomplete\srun\sof\squick.test\swith\smutex\sdebugging\senabled.\s(CVS\s4266)
+D 2007-08-22T02:56:43
F Makefile.in 0c0e53720f658c7a551046442dd7afba0b72bfbe
F Makefile.linux-gcc 65241babba6faf1152bf86574477baab19190499
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
F src/analyze.c a14237d869c6bea0846493b59317e4097e81a0b6
F src/attach.c a52225c75b107be8c5bc144a2b6d20201be3f8f8
F src/auth.c 083c1205b45e3f52291ec539d396b4fc557856b3
-F src/btree.c e35f1d7d662681a567cafaef6dba529ccd577a0d
-F src/btree.h aeb85d6a48573785666fb97566bf5802d5f9b7ca
+F src/btree.c 3e935a3074bfa498e74dc70f441cab64d364eab1
+F src/btree.h 76c89673981cb77575300c0b78a76eaa00a28743
F src/btreeInt.h 7fc6e51dc3d4bbed15639a8ea1aae737631d6670
F src/build.c 2159551184160e2cf17ff945e9a05fbe6f331c3d
F src/callback.c fdd527372162a974094103eae82119fcfcf11260
F src/legacy.c a83519a8fbb488c3155fca577b010d590ec479e9
F src/limits.h 71ab25f17e35e0a9f3f6f234b8ed49cc56731d35
F src/loadext.c dd803303fd06ef0b13913faaa4a7fc7d8c8c4e77
-F src/main.c 316381eeaf9c166a9edfe0e7d65b363432ed95ca
+F src/main.c ea11ee57f35ba85feb3c1f8ca81ac9caad718be2
F src/malloc.c f5ace943194fba04f09b590496a751a5ed6734f1
F src/md5.c c5fdfa5c2593eaee2e32a5ce6c6927c986eaf217
F src/mem1.c 30bf8be3846f92fdf88c490c5e5378512383bcbe
F src/mem2.c 482f0aaf14e8ef1db64cb8c5b9a9bfe708297c92
-F src/mutex.c 839c4226939081a4b736bb7ab6520b2f835be8ae
+F src/mutex.c 9cf641f556a4119ef90ed41b82f2d5647f81686e
F src/os.c 89b93d67bc436c2d9df4b5d296f30a59144e55bb
F src/os.h 399c89cafa93b9ef35c3dc70f77644d10936b535
F src/os_common.h a5c446d3b93f09f369d13bf217de4bed3437dd1c
F src/pager.h 53087c6fb9db01aed17c7fd044662a27507e89b8
F src/parse.y 2d2ce439dc6184621fb0b86f4fc5aca7f391a590
F src/pragma.c 9b989506a1b7c8aecd6befb8235e2f57a4aba7e5
-F src/prepare.c 7c11bab711f44ef12950816a8cfe495ccb295648
+F src/prepare.c 29ea14cf6b0558f2f80aa53e112bff55f1119e36
F src/printf.c a8f46e0ed360c18d40e89aa636533be300b406c2
F src/random.c 4a22746501bf36b0a088c66e38dde5daba6a35da
F src/select.c 98c367bce3f38c5adfcc97de9ab5c79b0e5dc2b2
F src/sqliteLimit.h f14609c27636ebc217c9603ade26dbdd7d0f6afa
F src/table.c c725e47f6f3092b9a7b569fc58e408e2173ee008
F src/tclsqlite.c 92e06e076d613484aa2afc5ad830d9080de92347
-F src/test1.c d665d85c7a4e4aef588d5c6f01761082358d291d
+F src/test1.c d7b8d6d15d10cc2e21f7a20a09c914d5aa84f1e2
F src/test2.c 4f742e99ed1bea5c14692f627bdb59a146f30504
-F src/test3.c 2e4da0fe90a0aa8cf9276ea34cbe92e91dc1db07
+F src/test3.c a7d011c51d6b2e2a73c43983d5c2b731d69c74d7
F src/test4.c d97b87919dc3db1cc5fccc04a33f030d5940e1a9
F src/test5.c 3a6a5717a149d7ca2e6d14f5be72cf7555d54dc4
F src/test6.c da83a0e49c03e8a25f4ce6e25c537c6617c14fc0
F src/vdbe.c 9d4d00589c174aad9a616f1615464ddddebba0ec
F src/vdbe.h 001c5b257567c1d3de7feb2203aac71d0d7b16a3
F src/vdbeInt.h 39fb069ce04137545ca0bc790f80ddc64a8c99d9
-F src/vdbeapi.c 62cc5b08fc33c05fe8a74b6bd78aff5e0c0ba4f2
+F src/vdbeapi.c 81cb7f018e56c20b40365f005ff69e1af9ea9494
F src/vdbeaux.c b0aeed4ff33352904b392ee6c7408bae5b141b9b
F src/vdbeblob.c d12ed95dac0992e1e372d079d76af047cc42f7c7
F src/vdbefifo.c 334c838c8f42d61a94813d136019ee566b5dc2f6
F src/vdbemem.c 3de25d78e7b1d0af7a05199de905cea8c43aed5d
-F src/vtab.c ee29237ecc9b310dc43c0c2ac5caa6c6a20787be
+F src/vtab.c 8f80924af48fc2295d36f6fe360d3c99ae968f9d
F src/where.c 2776a0caf8cbbfd6ec79cfb1cd9bc25074055e5e
F tclinstaller.tcl 4356d9d94d2b5ed5e68f9f0c80c4df3048dd7617
F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
F test/btree8.test fadc112bcbd6a0c622d34c813fc8a648eacf8804
F test/btree9.test 5d8711b241145b90f65dd1795d5dd8290846fa5e
F test/busy.test 0271c854738e23ad76e10d4096a698e5af29d211
-F test/cache.test 008668c54b38ba5b4c1134ba51447b01ac5520ec
+F test/cache.test 3ff445c445742a7b6b9ba6e1d62a25263f9424b9
F test/capi2.test 3c5066836cbaa9923bcc8282c010aa227bb5efd4
-F test/capi3.test f4e77c300d870653f9fc1b20bef6788f0790b3f1
+F test/capi3.test b436e762c01a9cb2235d4de8b55af3b887f0e384
F test/capi3b.test 664eb55318132f292f2c436f90906f578cad6b97
F test/capi3c.test 76a3fb94755288a2977ee387e95305e6224c0198
F test/cast.test c4780b58b569bab4947458195410ae8791ac216b
F test/icu.test e6bfae7f625c88fd14df6f540fe835bdfc1e4329
F test/in.test 369cb2aa1eab02296b4ec470732fe8c131260b1d
F test/in2.test b1f447f4f0f67e9f83ff931e7e2e30873f9ea055
-F test/incrblob.test 4d3d19f4001fe038cfed54f2119b0ec090317577
+F test/incrblob.test 7f95c929b719626443a996b105d2b0ff06f47818
F test/incrblob_err.test 2501bec57e317e7051451b5093b47fc61a96c85a
F test/incrvacuum.test 569347726ea5940c3359e3d8cabb3505595cb82f
F test/incrvacuum2.test 82397ceb5941cbe852fd29bb33fcdf5665bc80c2
F test/insert4.test 1e27f0a3e5670d5f03c1636f699aa44270945bca
F test/interrupt.test 81555fb0f8179bb2d0dc7151fd75428223f93cf2
F test/intpkey.test af4fd826c4784ec5c93b444de07adea0254d0d30
-F test/io.test b2f21c23f920541ba64e7b3251674bd8773c6bc8
+F test/io.test 6b7ee16f78560c4b81b52da2ea1051b8a2a93ce3
F test/ioerr.test 491d42c49bbec598966d26b01ed7901f55e5ee2d
F test/ioerr2.test f938eadb12108048813869b86beee4a2f98e34b8
F test/join.test af0443185378b64878750aa1cf4b83c216f246b4
F test/sort.test 0e4456e729e5a92a625907c63dcdedfbe72c5dc5
F test/speed1.test 22e1b27af0683ed44dcd2f93ed817a9c3e65084a
F test/speed2.test 53177056baf6556dcbdcf032bbdfc41c1aa74ded
-F test/speed3.test 27a71b5cc83c1f23baf6d0ee52e2f195e3c415f2
+F test/speed3.test 55e039b34d505aa442cee415f83c451ae28b3123
F test/sqllimits1.test c74c7cdbb23406c5408d2d9ddbe7da5b5a946c46
F test/subquery.test ae324ee928c5fb463a3ce08a8860d6e7f1ca5797
F test/subselect.test 974e87f8fc91c5f00dd565316d396a5a6c3106c4
F test/vacuum2.test e198d81a1cbc3f3f6b8aeee27cadfffea8995d42
F test/varint.test ab7b110089a08b9926ed7390e7e97bdefeb74102
F test/view.test 852bd4101e6d171c46ad682eb5c5faf662b2eba4
-F test/vtab1.test e740d4761b9125e6e541c62d199a3822f54614ff
+F test/vtab1.test f05e77fa16c6e5a6a7fea4b5e9a97f36ee78fdae
F test/vtab2.test 94bb3bf691ac10e34cf7dad46b1cf94b861d513c
F test/vtab3.test f38d6d7d19f08bffdadce4d5b8cba078f8118587
F test/vtab4.test a9d7104d41a787754a734740d7aa61c807a69f87
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
-P 0f7941aef976aa4f3be3e0046edd1ae042e5d9a3
-R a1e419f66e7c78d94227b10198dd19bc
+P 1914044b8832041f13b20ead613bd13725425d7a
+R da84160f0df065e75198c0663969de9f
U drh
-Z 60989ee4c1d273be71e169d0d08476db
+Z 4868a722cbf9dfdb786e2878b91cc4b4
** May you share freely, never taking more than you give.
**
*************************************************************************
-** $Id: btree.c,v 1.407 2007/08/22 00:39:20 drh Exp $
+** $Id: btree.c,v 1.408 2007/08/22 02:56:43 drh Exp $
**
** This file implements a external (disk-based) database using BTrees.
** See the header comment on "btreeInt.h" for additional information.
BtShared *pBt = p->pBt;
BtLock *pIter;
- assert( sqlite3_mutex_held(pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(pBt->mutex) );
/* This is a no-op if the shared-cache is not enabled */
if( !p->sharable ){
BtLock *pLock = 0;
BtLock *pIter;
- assert( sqlite3_mutex_held(pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(pBt->mutex) );
/* This is a no-op if the shared-cache is not enabled */
if( !p->sharable ){
static void unlockAllTables(Btree *p){
BtLock **ppIter = &p->pBt->pLock;
- assert( sqlite3_mutex_held(p->pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(p->pBt->mutex) );
assert( p->sharable || 0==*ppIter );
while( *ppIter ){
*/
static void invalidateAllOverflowCache(BtShared *pBt){
BtCursor *p;
- assert( sqlite3_mutex_held(pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(pBt->mutex) );
for(p=pBt->pCursor; p; p=p->pNext){
invalidateOverflowCache(p);
}
assert( CURSOR_VALID==pCur->eState );
assert( 0==pCur->pKey );
- assert( sqlite3_mutex_held(pCur->pBtree->pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(pCur->pBtree->pBt->mutex) );
rc = sqlite3BtreeKeySize(pCur, &pCur->nKey);
*/
static int saveAllCursors(BtShared *pBt, Pgno iRoot, BtCursor *pExcept){
BtCursor *p;
- assert( sqlite3_mutex_held(pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(pBt->mutex) );
for(p=pBt->pCursor; p; p=p->pNext){
if( p!=pExcept && (0==iRoot || p->pgnoRoot==iRoot) &&
p->eState==CURSOR_VALID ){
** Clear the current cursor position.
*/
static void clearCursorPosition(BtCursor *pCur){
- assert( sqlite3_mutex_held(pCur->pBtree->pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(pCur->pBtree->pBt->mutex) );
sqlite3_free(pCur->pKey);
pCur->pKey = 0;
pCur->eState = CURSOR_INVALID;
*/
static Pgno ptrmapPageno(BtShared *pBt, Pgno pgno){
int nPagesPerMapPage, iPtrMap, ret;
- assert( sqlite3_mutex_held(pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(pBt->mutex) );
nPagesPerMapPage = (pBt->usableSize/5)+1;
iPtrMap = (pgno-2)/nPagesPerMapPage;
ret = (iPtrMap*nPagesPerMapPage) + 2;
int offset; /* Offset in pointer map page */
int rc;
- assert( sqlite3_mutex_held(pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(pBt->mutex) );
/* The master-journal page number must never be used as a pointer map page */
assert( 0==PTRMAP_ISPAGE(pBt, PENDING_BYTE_PAGE(pBt)) );
int offset; /* Offset of entry in pointer map */
int rc;
- assert( sqlite3_mutex_held(pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(pBt->mutex) );
iPtrmap = PTRMAP_PAGENO(pBt, key);
rc = sqlite3PagerGet(pBt->pPager, iPtrmap, &pDbPage);
*/
static u8 *findOverflowCell(MemPage *pPage, int iCell){
int i;
- assert( sqlite3_mutex_held(pPage->pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(pPage->pBt->mutex) );
for(i=pPage->nOverflow-1; i>=0; i--){
int k;
struct _OvflCell *pOvfl;
int n; /* Number bytes in cell content header */
u32 nPayload; /* Number of bytes of cell payload */
- assert( sqlite3_mutex_held(pPage->pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(pPage->pBt->mutex) );
pInfo->pCell = pCell;
assert( pPage->leaf==0 || pPage->leaf==1 );
*/
static int ptrmapPutOvfl(MemPage *pPage, int iCell){
u8 *pCell;
- assert( sqlite3_mutex_held(pPage->pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(pPage->pBt->mutex) );
pCell = findOverflowCell(pPage, iCell);
return ptrmapPutOvflPtr(pPage, pCell);
}
assert( pPage->pBt!=0 );
assert( pPage->pBt->usableSize <= SQLITE_MAX_PAGE_SIZE );
assert( pPage->nOverflow==0 );
- assert( sqlite3_mutex_held(pPage->pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(pPage->pBt->mutex) );
temp = sqlite3_malloc( pPage->pBt->pageSize );
if( temp==0 ) return SQLITE_NOMEM;
data = pPage->aData;
data = pPage->aData;
assert( sqlite3PagerIswriteable(pPage->pDbPage) );
assert( pPage->pBt );
- assert( sqlite3_mutex_held(pPage->pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(pPage->pBt->mutex) );
if( nByte<4 ) nByte = 4;
if( pPage->nFree<nByte || pPage->nOverflow>0 ) return 0;
pPage->nFree -= nByte;
assert( sqlite3PagerIswriteable(pPage->pDbPage) );
assert( start>=pPage->hdrOffset+6+(pPage->leaf?0:4) );
assert( (start + size)<=pPage->pBt->usableSize );
- assert( sqlite3_mutex_held(pPage->pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(pPage->pBt->mutex) );
if( size<4 ) size = 4;
#ifdef SQLITE_SECURE_DELETE
BtShared *pBt; /* A copy of pPage->pBt */
assert( pPage->hdrOffset==(pPage->pgno==1 ? 100 : 0) );
- assert( sqlite3_mutex_held(pPage->pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(pPage->pBt->mutex) );
pPage->intKey = (flagByte & (PTF_INTKEY|PTF_LEAFDATA))!=0;
pPage->zeroData = (flagByte & PTF_ZERODATA)!=0;
pPage->leaf = (flagByte & PTF_LEAF)!=0;
pBt = pPage->pBt;
assert( pBt!=0 );
assert( pParent==0 || pParent->pBt==pBt );
- assert( sqlite3_mutex_held(pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(pBt->mutex) );
assert( pPage->pgno==sqlite3PagerPagenumber(pPage->pDbPage) );
assert( pPage->aData == &((unsigned char*)pPage)[-pBt->pageSize] );
if( pPage->pParent!=pParent && (pPage->pParent!=0 || pPage->isInit) ){
assert( sqlite3PagerPagenumber(pPage->pDbPage)==pPage->pgno );
assert( &data[pBt->pageSize] == (unsigned char*)pPage );
assert( sqlite3PagerIswriteable(pPage->pDbPage) );
- assert( sqlite3_mutex_held(pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(pBt->mutex) );
memset(&data[hdr], 0, pBt->usableSize - hdr);
data[hdr] = flags;
first = hdr + 8 + 4*((flags&PTF_LEAF)==0);
MemPage *pPage;
DbPage *pDbPage;
- assert( sqlite3_mutex_held(pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(pBt->mutex) );
rc = sqlite3PagerAcquire(pBt->pPager, pgno, (DbPage**)&pDbPage, noContent);
if( rc ) return rc;
pPage = (MemPage *)sqlite3PagerGetExtra(pDbPage);
MemPage *pParent /* Parent of the page */
){
int rc;
- assert( sqlite3_mutex_held(pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(pBt->mutex) );
if( pgno==0 ){
return SQLITE_CORRUPT_BKPT;
}
assert( pPage->aData );
assert( pPage->pBt );
assert( &pPage->aData[pPage->pBt->pageSize]==(unsigned char*)pPage );
- assert( sqlite3_mutex_held(pPage->pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(pPage->pBt->mutex) );
sqlite3PagerUnref(pPage->pDbPage);
}
}
pPage = (MemPage *)sqlite3PagerGetExtra(pData);
if( pPage->pParent ){
MemPage *pParent = pPage->pParent;
- assert( sqlite3_mutex_held(pPage->pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(pPage->pBt->mutex) );
pPage->pParent = 0;
releasePage(pParent);
}
assert( (pageSize & 7)==0 );
pPage = (MemPage *)sqlite3PagerGetExtra(pData);
if( pPage->isInit ){
- assert( sqlite3_mutex_held(pPage->pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(pPage->pBt->mutex) );
pPage->isInit = 0;
sqlite3BtreeInitPage(pPage, pPage->pParent);
}
}else{
pVfs = sqlite3_vfs_find(0);
}
- assert( pSqlite==0 || sqlite3_mutex_held(pSqlite->mutex) );
+ assert( sqlite3BtreeMutexHeld(pSqlite->mutex) );
/* Set the variable isMemdb to true for an in-memory database, or
** false for a file-based database. This symbol is only required if
assert( p->sharable || p->wantToLock==0 );
/* We should already hold a lock on the database connection */
- assert( sqlite3_mutex_held(p->pSqlite->mutex) );
+ assert( sqlite3BtreeMutexHeld(p->pSqlite->mutex) );
if( !p->sharable ) return;
p->wantToLock++;
int rc, pageSize;
MemPage *pPage1;
- assert( sqlite3_mutex_held(pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(pBt->mutex) );
if( pBt->pPage1 ) return SQLITE_OK;
rc = sqlite3BtreeGetPage(pBt, 1, &pPage1, 0);
if( rc!=SQLITE_OK ) return rc;
static int lockBtreeWithRetry(Btree *pRef){
int rc = SQLITE_OK;
- assert( sqlite3_mutex_held(pRef->pSqlite->mutex) );
- assert( sqlite3_mutex_held(pRef->pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(pRef->pSqlite->mutex) );
+ assert( sqlite3BtreeMutexHeld(pRef->pBt->mutex) );
if( pRef->inTrans==TRANS_NONE ){
u8 inTransaction = pRef->pBt->inTransaction;
btreeIntegrity(pRef);
** If there is a transaction in progress, this routine is a no-op.
*/
static void unlockBtreeIfUnused(BtShared *pBt){
- assert( sqlite3_mutex_held(pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(pBt->mutex) );
if( pBt->inTransaction==TRANS_NONE && pBt->pCursor==0 && pBt->pPage1!=0 ){
if( sqlite3PagerRefcount(pBt->pPager)>=1 ){
if( pBt->pPage1->aData==0 ){
unsigned char *data;
int rc;
- assert( sqlite3_mutex_held(pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(pBt->mutex) );
if( sqlite3PagerPagecount(pBt->pPager)>0 ) return SQLITE_OK;
pP1 = pBt->pPage1;
assert( pP1!=0 );
int isInitOrig = pPage->isInit;
Pgno pgno = pPage->pgno;
- assert( sqlite3_mutex_held(pPage->pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(pPage->pBt->mutex) );
rc = sqlite3BtreeInitPage(pPage, pPage->pParent);
if( rc!=SQLITE_OK ){
goto set_child_ptrmaps_out;
** overflow page in the list.
*/
static int modifyPagePointer(MemPage *pPage, Pgno iFrom, Pgno iTo, u8 eType){
- assert( sqlite3_mutex_held(pPage->pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(pPage->pBt->mutex) );
if( eType==PTRMAP_OVERFLOW2 ){
/* The pointer is always the first 4 bytes of the page in this case. */
if( get4byte(pPage->aData)!=iFrom ){
assert( eType==PTRMAP_OVERFLOW2 || eType==PTRMAP_OVERFLOW1 ||
eType==PTRMAP_BTREE || eType==PTRMAP_ROOTPAGE );
- assert( sqlite3_mutex_held(pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(pBt->mutex) );
/* Move page iDbPage from it's current location to page number iFreePage */
TRACE(("AUTOVACUUM: Moving %d to free page %d (ptr page %d type %d)\n",
Pgno iLastPg; /* Last page in the database */
Pgno nFreeList; /* Number of pages still on the free-list */
- assert( sqlite3_mutex_held(pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(pBt->mutex) );
iLastPg = pBt->nTrunc;
if( iLastPg==0 ){
iLastPg = sqlite3PagerPagecount(pBt->pPager);
int nRef = sqlite3PagerRefcount(pPager);
#endif
- assert( sqlite3_mutex_held(pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(pBt->mutex) );
invalidateAllOverflowCache(pBt);
assert(pBt->autoVacuum);
if( !pBt->incrVacuum ){
BtCursor *pCur;
BtShared *pBt = p->pBt;
- assert( sqlite3_mutex_held(pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(pBt->mutex) );
*ppCur = 0;
if( wrFlag ){
if( pBt->readOnly ){
Pgno next = 0;
int rc;
- assert( sqlite3_mutex_held(pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(pBt->mutex) );
/* One of these must not be NULL. Otherwise, why call this function? */
assert(ppPage || pPgnoNext);
assert( pCur->eState==CURSOR_VALID );
assert( pCur->idx>=0 && pCur->idx<pPage->nCell );
assert( offset>=0 );
- assert( sqlite3_mutex_held(pCur->pBtree->pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(pCur->pBtree->pBt->mutex) );
getCellInfo(pCur);
aPayload = pCur->info.pCell + pCur->info.nHeader;
assert( pCur!=0 && pCur->pPage!=0 );
assert( pCur->eState==CURSOR_VALID );
- assert( sqlite3_mutex_held(pCur->pBtree->pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(pCur->pBtree->pBt->mutex) );
pPage = pCur->pPage;
assert( pCur->idx>=0 && pCur->idx<pPage->nCell );
getCellInfo(pCur);
** in the common case where no overflow pages are used.
*/
const void *sqlite3BtreeKeyFetch(BtCursor *pCur, int *pAmt){
- assert( sqlite3_mutex_held(pCur->pBtree->pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(pCur->pBtree->pBt->mutex) );
if( pCur->eState==CURSOR_VALID ){
return (const void*)fetchPayload(pCur, pAmt, 0);
}
return 0;
}
const void *sqlite3BtreeDataFetch(BtCursor *pCur, int *pAmt){
- assert( sqlite3_mutex_held(pCur->pBtree->pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(pCur->pBtree->pBt->mutex) );
if( pCur->eState==CURSOR_VALID ){
return (const void*)fetchPayload(pCur, pAmt, 1);
}
MemPage *pOldPage;
BtShared *pBt = pCur->pBtree->pBt;
- assert( sqlite3_mutex_held(pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(pBt->mutex) );
assert( pCur->eState==CURSOR_VALID );
rc = getAndInitPage(pBt, newPgno, &pNewPage, pCur->pPage);
if( rc ) return rc;
int sqlite3BtreeIsRootPage(MemPage *pPage){
MemPage *pParent;
- assert( sqlite3_mutex_held(pPage->pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(pPage->pBt->mutex) );
pParent = pPage->pParent;
if( pParent==0 ) return 1;
if( pParent->pgno>1 ) return 0;
Btree *p = pCur->pBtree;
BtShared *pBt = p->pBt;
- assert( sqlite3_mutex_held(p->pSqlite->mutex) );
- assert( sqlite3_mutex_held(pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(p->pSqlite->mutex) );
+ assert( sqlite3BtreeMutexHeld(pBt->mutex) );
if( pCur->eState==CURSOR_REQUIRESEEK ){
clearCursorPosition(pCur);
}
int rc = SQLITE_OK;
MemPage *pPage;
- assert( sqlite3_mutex_held(pCur->pBtree->pBt->mutex) );
- assert( sqlite3_mutex_held(pCur->pBtree->pSqlite->mutex) );
+ assert( sqlite3BtreeMutexHeld(pCur->pBtree->pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(pCur->pBtree->pSqlite->mutex) );
assert( pCur->eState==CURSOR_VALID );
while( rc==SQLITE_OK && !(pPage = pCur->pPage)->leaf ){
assert( pCur->idx>=0 && pCur->idx<pPage->nCell );
int rc = SQLITE_OK;
MemPage *pPage;
- assert( sqlite3_mutex_held(pCur->pBtree->pBt->mutex) );
- assert( sqlite3_mutex_held(pCur->pBtree->pSqlite->mutex) );
+ assert( sqlite3BtreeMutexHeld(pCur->pBtree->pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(pCur->pBtree->pSqlite->mutex) );
assert( pCur->eState==CURSOR_VALID );
while( rc==SQLITE_OK && !(pPage = pCur->pPage)->leaf ){
pgno = get4byte(&pPage->aData[pPage->hdrOffset+8]);
int sqlite3BtreeFirst(BtCursor *pCur, int *pRes){
int rc;
- assert( sqlite3_mutex_held(pCur->pBtree->pBt->mutex) );
- assert( sqlite3_mutex_held(pCur->pBtree->pSqlite->mutex) );
+ assert( sqlite3BtreeMutexHeld(pCur->pBtree->pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(pCur->pBtree->pSqlite->mutex) );
rc = moveToRoot(pCur);
if( rc==SQLITE_OK ){
if( pCur->eState==CURSOR_INVALID ){
int sqlite3BtreeLast(BtCursor *pCur, int *pRes){
int rc;
- assert( sqlite3_mutex_held(pCur->pBtree->pBt->mutex) );
- assert( sqlite3_mutex_held(pCur->pBtree->pSqlite->mutex) );
+ assert( sqlite3BtreeMutexHeld(pCur->pBtree->pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(pCur->pBtree->pSqlite->mutex) );
rc = moveToRoot(pCur);
if( rc==SQLITE_OK ){
if( CURSOR_INVALID==pCur->eState ){
){
int rc;
- assert( sqlite3_mutex_held(pCur->pBtree->pBt->mutex) );
- assert( sqlite3_mutex_held(pCur->pBtree->pSqlite->mutex) );
+ assert( sqlite3BtreeMutexHeld(pCur->pBtree->pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(pCur->pBtree->pSqlite->mutex) );
rc = moveToRoot(pCur);
if( rc ){
return rc;
MemPage *pTrunk = 0;
MemPage *pPrevTrunk = 0;
- assert( sqlite3_mutex_held(pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(pBt->mutex) );
pPage1 = pBt->pPage1;
n = get4byte(&pPage1->aData[36]);
if( n>0 ){
int rc, n, k;
/* Prepare the page for freeing */
- assert( sqlite3_mutex_held(pPage->pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(pPage->pBt->mutex) );
assert( pPage->pgno>1 );
pPage->isInit = 0;
releasePage(pPage->pParent);
int nOvfl;
int ovflPageSize;
- assert( sqlite3_mutex_held(pPage->pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(pPage->pBt->mutex) );
sqlite3BtreeParseCellPtr(pPage, pCell, &info);
if( info.iOverflow==0 ){
return SQLITE_OK; /* No overflow pages. Return without doing anything */
int nHeader;
CellInfo info;
- assert( sqlite3_mutex_held(pPage->pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(pPage->pBt->mutex) );
/* Fill in the header. */
nHeader = 0;
MemPage *pThis;
DbPage *pDbPage;
- assert( sqlite3_mutex_held(pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(pBt->mutex) );
assert( pNewParent!=0 );
if( pgno==0 ) return SQLITE_OK;
assert( pBt->pPager!=0 );
BtShared *pBt = pPage->pBt;
int rc = SQLITE_OK;
- assert( sqlite3_mutex_held(pPage->pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(pPage->pBt->mutex) );
if( pPage->leaf ) return SQLITE_OK;
for(i=0; i<pPage->nCell; i++){
assert( idx>=0 && idx<pPage->nCell );
assert( sz==cellSize(pPage, idx) );
assert( sqlite3PagerIswriteable(pPage->pDbPage) );
- assert( sqlite3_mutex_held(pPage->pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(pPage->pBt->mutex) );
data = pPage->aData;
ptr = &data[pPage->cellOffset + 2*idx];
pc = get2byte(ptr);
assert( i>=0 && i<=pPage->nCell+pPage->nOverflow );
assert( sz==cellSizePtr(pPage, pCell) );
- assert( sqlite3_mutex_held(pPage->pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(pPage->pBt->mutex) );
if( pPage->nOverflow || sz+2>pPage->nFree ){
if( pTemp ){
memcpy(pTemp+nSkip, pCell+nSkip, sz-nSkip);
u8 *data; /* Data for the page */
assert( pPage->nOverflow==0 );
- assert( sqlite3_mutex_held(pPage->pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(pPage->pBt->mutex) );
totalSize = 0;
for(i=0; i<nCell; i++){
totalSize += aSize[i];
int parentSize; /* Size of new divider cell */
u8 parentCell[64]; /* Space for the new divider cell */
- assert( sqlite3_mutex_held(pPage->pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(pPage->pBt->mutex) );
/* Allocate a new page. Insert the overflow cell from pPage
** into it. Then remove the overflow cell from pPage.
u8 *aFrom = 0;
#endif
- assert( sqlite3_mutex_held(pPage->pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(pPage->pBt->mutex) );
/*
** Find the parent page.
assert( pPage->pParent==0 );
assert( pPage->nCell==0 );
- assert( sqlite3_mutex_held(pPage->pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(pPage->pBt->mutex) );
pBt = pPage->pBt;
mxCellPerPage = MX_CELL(pBt);
apCell = sqlite3_malloc( mxCellPerPage*(sizeof(u8*)+sizeof(int)) );
assert( pPage->pParent==0 );
assert( pPage->nOverflow>0 );
pBt = pPage->pBt;
- assert( sqlite3_mutex_held(pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(pBt->mutex) );
rc = allocateBtreePage(pBt, &pChild, &pgnoChild, pPage->pgno, 0);
if( rc ) return rc;
assert( sqlite3PagerIswriteable(pChild->pDbPage) );
*/
static int balance(MemPage *pPage, int insert){
int rc = SQLITE_OK;
- assert( sqlite3_mutex_held(pPage->pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(pPage->pBt->mutex) );
if( pPage->pParent==0 ){
rc = sqlite3PagerWrite(pPage->pDbPage);
if( rc==SQLITE_OK && pPage->nOverflow>0 ){
BtCursor *p;
BtShared *pBt = pBtree->pBt;
sqlite3 *db = pBtree->pSqlite;
- assert( sqlite3_mutex_held(pBt->mutex) );
- assert( sqlite3_mutex_held(db->mutex) );
+ assert( sqlite3BtreeMutexHeld(pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(db->mutex) );
for(p=pBt->pCursor; p; p=p->pNext){
if( p==pExclude ) continue;
if( p->eState!=CURSOR_VALID ) continue;
unsigned char *pCell;
int i;
- assert( sqlite3_mutex_held(pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(pBt->mutex) );
if( pgno>sqlite3PagerPagecount(pBt->pPager) ){
return SQLITE_CORRUPT_BKPT;
}
MemPage *pPage = 0;
BtShared *pBt = p->pBt;
- assert( sqlite3_mutex_held(pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(pBt->mutex) );
if( p->inTrans!=TRANS_WRITE ){
return pBt->readOnly ? SQLITE_READONLY : SQLITE_ERROR;
}
** restoreOrClearCursorPosition() here.
*/
MemPage *pPage = pCur->pPage;
- assert( sqlite3_mutex_held(pPage->pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(pPage->pBt->mutex) );
return pPage ? pPage->aData[pPage->hdrOffset] : 0;
}
** testing and debugging only.
*/
Pager *sqlite3BtreePager(Btree *p){
- assert( sqlite3_mutex_held(p->pSqlite->mutex) );
- assert( sqlite3_mutex_held(p->pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(p->pSqlite->mutex) );
+ assert( sqlite3BtreeMutexHeld(p->pBt->mutex) );
return p->pBt->pPager;
}
*/
const char *sqlite3BtreeGetFilename(Btree *p){
assert( p->pBt->pPager!=0 );
- assert( sqlite3_mutex_held(p->pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(p->pBt->mutex) );
return sqlite3PagerFilename(p->pBt->pPager);
}
*/
const char *sqlite3BtreeGetDirname(Btree *p){
assert( p->pBt->pPager!=0 );
- assert( sqlite3_mutex_held(p->pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(p->pBt->mutex) );
return sqlite3PagerDirname(p->pBt->pPager);
}
*/
const char *sqlite3BtreeGetJournalname(Btree *p){
assert( p->pBt->pPager!=0 );
- assert( sqlite3_mutex_held(p->pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(p->pBt->mutex) );
return sqlite3PagerJournalname(p->pBt->pPager);
}
** Return non-zero if a transaction is active.
*/
int sqlite3BtreeIsInTrans(Btree *p){
- assert( sqlite3_mutex_held(p->pBt->mutex) );
- assert( sqlite3_mutex_held(p->pSqlite->mutex) );
+ assert( sqlite3BtreeMutexHeld(p->pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(p->pSqlite->mutex) );
return (p && (p->inTrans==TRANS_WRITE));
}
** Return non-zero if a statement transaction is active.
*/
int sqlite3BtreeIsInStmt(Btree *p){
- assert( sqlite3_mutex_held(p->pBt->mutex) );
- assert( sqlite3_mutex_held(p->pSqlite->mutex) );
+ assert( sqlite3BtreeMutexHeld(p->pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(p->pSqlite->mutex) );
return (p->pBt && p->pBt->inStmt);
}
** Return non-zero if a read (or write) transaction is active.
*/
int sqlite3BtreeIsInReadTrans(Btree *p){
- assert( sqlite3_mutex_held(p->pBt->mutex) );
- assert( sqlite3_mutex_held(p->pSqlite->mutex) );
+ assert( sqlite3BtreeMutexHeld(p->pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(p->pSqlite->mutex) );
return (p && (p->inTrans!=TRANS_NONE));
}
*/
void *sqlite3BtreeSchema(Btree *p, int nBytes, void(*xFree)(void *)){
BtShared *pBt = p->pBt;
- assert( sqlite3_mutex_held(pBt->mutex) );
- assert( sqlite3_mutex_held(p->pSqlite->mutex) );
+ assert( sqlite3BtreeMutexHeld(p->pSqlite->mutex) );
+ sqlite3BtreeEnter(p);
if( !pBt->pSchema ){
pBt->pSchema = sqlite3MallocZero(nBytes);
pBt->xFreeSchema = xFree;
}
+ sqlite3BtreeLeave(p);
return pBt->pSchema;
}
** handle holds an exclusive lock on the sqlite_master table.
*/
int sqlite3BtreeSchemaLocked(Btree *p){
- assert( sqlite3_mutex_held(p->pBt->mutex) );
- assert( sqlite3_mutex_held(p->pSqlite->mutex) );
- return (queryTableLock(p, MASTER_ROOT, READ_LOCK)!=SQLITE_OK);
+ int rc;
+ assert( sqlite3BtreeMutexHeld(p->pSqlite->mutex) );
+ sqlite3BtreeEnter(p);
+ rc = (queryTableLock(p, MASTER_ROOT, READ_LOCK)!=SQLITE_OK);
+ sqlite3BtreeLeave(p);
+ return rc;
}
** to change the length of the data stored.
*/
int sqlite3BtreePutData(BtCursor *pCsr, u32 offset, u32 amt, void *z){
- assert( sqlite3_mutex_held(pCsr->pBtree->pBt->mutex) );
- assert( sqlite3_mutex_held(pCsr->pBtree->pSqlite->mutex) );
+ assert( sqlite3BtreeMutexHeld(pCsr->pBtree->pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(pCsr->pBtree->pSqlite->mutex) );
assert(pCsr->isIncrblobHandle);
if( pCsr->eState==CURSOR_REQUIRESEEK ){
return SQLITE_ABORT;
** sqlite3BtreePutData()).
*/
void sqlite3BtreeCacheOverflow(BtCursor *pCur){
- assert( sqlite3_mutex_held(pCur->pBtree->pBt->mutex) );
- assert( sqlite3_mutex_held(pCur->pBtree->pSqlite->mutex) );
+ assert( sqlite3BtreeMutexHeld(pCur->pBtree->pBt->mutex) );
+ assert( sqlite3BtreeMutexHeld(pCur->pBtree->pSqlite->mutex) );
assert(!pCur->isIncrblobHandle);
assert(!pCur->aOverflow);
pCur->isIncrblobHandle = 1;