-C Fix\san\sissue\swith\sthe\spermutation\stest\sscript.\s(CVS\s5619)
-D 2008-08-26T23:08:04
+C Remove\sunreachable\sbranches\sfrom\spcache.c.\s(CVS\s5620)
+D 2008-08-27T09:44:40
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in 689e14735f862a5553bceef206d8c13e29504e44
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
F src/os_os2.c e391fc95adc744bbdcefd4d11e3066998185a0a0
F src/os_unix.c 4665cef7639dd937893c3ea076f0e8a8f215bb32
F src/os_win.c aefe9ee26430678a19a058a874e4e2bd91398142
-F src/pager.c 66836244eac6b1a46e8c26e3dd3c143031bf28e5
+F src/pager.c 095efa75a1a6500e6e975d1f7ddad34ed25424ae
F src/pager.h 3b9c138d2e744b9d6e61d4c2742301e3bf464864
F src/parse.y d0f76d2cb8d6883d5600dc20beb961a6022b94b8
-F src/pcache.c 006714ad89db3c488526246e6ed6b130e457f01b
+F src/pcache.c 9e00544dd8c2bc93087050fecad9767353a9b81d
F src/pcache.h 3531f83e1771442af16f6ffeac68024ff8c8bb2d
F src/pragma.c f5b271b090af7fcedd308d7c5807a5503f7a853d
F src/prepare.c c197041e0c4770672cda75e6bfe10242f885e510
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 1dbced29de5f59ba2ebf877edcadf171540374d1
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
-P 7e1032ab0031ba535f37b6338a3ac81cb1449d76
-R 5bb8278c25d388f413885c21aaec9f08
-U drh
-Z 29c1240c9559901eefb07c5d9ddca3ab
+P 2e12aa3e078c0da9e418ff1f25a08f05cd03c07d
+R bd0a0c9cdd657d12dbda9e1d4a16eb2b
+U danielk1977
+Z b519f55ef9a51e1605788897feb7c282
** file simultaneously, or one process from reading the database while
** another is writing.
**
-** @(#) $Id: pager.c,v 1.481 2008/08/26 21:07:27 drh Exp $
+** @(#) $Id: pager.c,v 1.482 2008/08/27 09:44:40 danielk1977 Exp $
*/
#ifndef SQLITE_OMIT_DISKIO
#include "sqliteInt.h"
if( rc!=SQLITE_OK ){
return rc;
}
- if( pPager->errCode && pPg->nRef==1 ){
- sqlite3PcacheDrop(pPg);
- return pPager->errCode;
- }
if( pPg->pPager==0 ){
/* The pager cache has created a new page. Its content needs to
** be initialized.
*************************************************************************
** This file implements that page cache.
**
-** @(#) $Id: pcache.c,v 1.15 2008/08/26 19:08:00 danielk1977 Exp $
+** @(#) $Id: pcache.c,v 1.16 2008/08/27 09:44:40 danielk1977 Exp $
*/
#include "sqliteInt.h"
**
** Return a pointer to the new page, or NULL if an OOM condition occurs.
*/
-static PgHdr *pcacheRecycleOrAlloc(PCache *pCache){
+static int pcacheRecycleOrAlloc(PCache *pCache, PgHdr **ppPage){
PgHdr *p = 0;
int szPage = pCache->szPage;
assert( pcache.isInit );
assert( sqlite3_mutex_notheld(pcache.mutex) );
+ *ppPage = 0;
pcacheEnterGlobal();
/* If we have reached the limit for pinned/dirty pages, and there is at
for(pPg=pCache->pDirtyTail; pPg && pPg->nRef; pPg=pPg->pPrev);
}
if( pPg ){
+ int rc;
pcacheExitGlobal();
- pCache->xStress(pCache->pStress, pPg);
+ rc = pCache->xStress(pCache->pStress, pPg);
+ if( rc!=SQLITE_OK ){
+ return rc;
+ }
pcacheEnterGlobal();
}
}
}
pcacheExitGlobal();
- return p;
+ *ppPage = p;
+ return (p?SQLITE_OK:SQLITE_NOMEM);
}
/*************************************************** General Interfaces ******
assert( pcache.isInit==0 );
memset(&pcache, 0, sizeof(pcache));
if( sqlite3Config.bCoreMutex ){
+ /* No need to check the return value of sqlite3_mutex_alloc().
+ ** Allocating a static mutex cannot fail.
+ */
pcache.mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_LRU);
- if( pcache.mutex==0 ){
- return SQLITE_NOMEM;
- }
}
pcache.isInit = 1;
return SQLITE_OK;
}
if( createFlag ){
+ int rc = SQLITE_OK;
if( pCache->nHash<=pCache->nPage ){
- int rc = pcacheResizeHash(pCache, pCache->nHash<256?256:pCache->nHash*2);
+ rc = pcacheResizeHash(pCache, pCache->nHash<256?256:pCache->nHash*2);
if( rc!=SQLITE_OK ){
return rc;
}
}
- pPage = pcacheRecycleOrAlloc(pCache);
- *ppPage = pPage;
- if( pPage==0 ){
- return SQLITE_NOMEM;
+ rc = pcacheRecycleOrAlloc(pCache, ppPage);
+ if( rc!=SQLITE_OK ){
+ return rc;
}
-
+ pPage = *ppPage;
pPage->pPager = 0;
pPage->flags = 0;
pPage->pDirty = 0;
}
/*
-** Drop a page from the cache. This should be the only reference to
-** the page.
+** Drop a page from the cache. There must be exactly one reference to the
+** page. This function deletes that reference, so after it returns the
+** page pointed to by p is invalid.
*/
void sqlite3PcacheDrop(PgHdr *p){
PCache *pCache;
assert( p->nRef==1 );
+ assert( 0==(p->flags&PGHDR_DIRTY) );
pCache = p->pCache;
pCache->nRef--;
pCache->nPinned--;
- if( p->flags & PGHDR_DIRTY ){
- pcacheRemoveFromList(&pCache->pDirty, p);
- }else{
- pcacheRemoveFromList(&pCache->pClean, p);
- }
+ pcacheRemoveFromList(&pCache->pClean, p);
pcacheRemoveFromHash(p);
pcacheEnterGlobal();
pcachePageFree(p);
}
if( 0==(andMask&PGHDR_NEED_SYNC) ){
- PgHdr *pSynced = pCache->pDirtyTail;
- while( pSynced && (pSynced->flags&PGHDR_NEED_SYNC) ){
- pSynced = pSynced->pPrev;
- }
- pCache->pSynced = pSynced;
+ pCache->pSynced = pCache->pDirtyTail;
+ assert( !pCache->pSynced || (pCache->pSynced->flags&PGHDR_NEED_SYNC)==0 );
}
pcacheExitGlobal();