From d8c0ba3b02aa16e9f248db1acc6a233eef62cc4e Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 30 Jun 2015 03:57:59 +0000 Subject: [PATCH] Optimization to the sqlite3PcacheFetch() logic. FossilOrigin-Name: d9a0481ce0fd9824b1566f182d68ec46ef091b1b --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/pager.c | 6 ++++++ src/pcache.c | 4 ++-- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 4773cc0264..6a222cd1bf 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Put\sall\svariable\sdeclarations\sfor\ssqlite3PagerWrite()\nat\sthe\sbeginning\sof\sthe\sblock.\s\sSyntax\sonly\s-\sno\slogic\schanges. -D 2015-06-30T03:34:13.376 +C Optimization\sto\sthe\ssqlite3PcacheFetch()\slogic. +D 2015-06-30T03:57:59.045 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 285a0a234ed7610d431d91671c136098c2bd86a9 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -314,10 +314,10 @@ F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa F src/os_unix.c 23eb5f56fac54d8fe0cb204291f3b3b2d94f23fc F src/os_win.c 27cc135e2d0b8b1e2e4944db1e2669a6a18fa0f8 F src/os_win.h eb7a47aa17b26b77eb97e4823f20a00b8bda12ca -F src/pager.c fbd0dd63da21d62c51e845b919548d6eb14dd2ff +F src/pager.c 3fa869dafdb59ece9d318177e3b9972039dfee39 F src/pager.h c3476e7c89cdf1c6914e50a11f3714e30b4e0a77 F src/parse.y 6d60dda8f8d418b6dc034f1fbccd816c459983a8 -F src/pcache.c 379fd77feb732b39750eb733260d9c227d8a4314 +F src/pcache.c cde06aa50962595e412d497e22fd2e07878ba1f0 F src/pcache.h 9968603796240cdf83da7e7bef76edf90619cea9 F src/pcache1.c 9ec20f98f50ed7415019303ae9bd3745d4b7bd9b F src/pragma.c c1f4d012ea9f6b1ce52d341b2cd0ad72d560afd7 @@ -1364,7 +1364,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 8001aa52bd12f900092387fe3571463e89efd977 -R 3ab730a0fd8ce3dab29c0f5735db472f +P a0fa6b3ba59716e53b8c035b497602050ed0ccb8 +R ef96145c17347794d738ef415b1d0f04 U drh -Z 2e2284bbdb4fcaa6c0dd63e70a1d9358 +Z a3fb1d60e02fc08f324c2aa0fa9d650d diff --git a/manifest.uuid b/manifest.uuid index c6fb62560a..caf2e1d807 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a0fa6b3ba59716e53b8c035b497602050ed0ccb8 \ No newline at end of file +d9a0481ce0fd9824b1566f182d68ec46ef091b1b \ No newline at end of file diff --git a/src/pager.c b/src/pager.c index dd3cac40a1..0ac05f715b 100644 --- a/src/pager.c +++ b/src/pager.c @@ -5312,6 +5312,11 @@ int sqlite3PagerAcquire( if( pBase==0 ){ rc = sqlite3PcacheFetchStress(pPager->pPCache, pgno, &pBase); if( rc!=SQLITE_OK ) goto pager_acquire_err; + if( pBase==0 ){ + pPg = *ppPage = 0; + rc = SQLITE_NOMEM; + goto pager_acquire_err; + } } pPg = *ppPage = sqlite3PcacheFetchFinish(pPager->pPCache, pgno, pBase); if( pPg==0 ) rc = SQLITE_NOMEM; @@ -5418,6 +5423,7 @@ DbPage *sqlite3PagerLookup(Pager *pPager, Pgno pgno){ assert( pPager->pPCache!=0 ); pPage = sqlite3PcacheFetch(pPager->pPCache, pgno, 0); assert( pPage==0 || pPager->hasBeenUsed ); + if( pPage==0 ) return 0; return sqlite3PcacheFetchFinish(pPager->pPCache, pgno, pPage); } diff --git a/src/pcache.c b/src/pcache.c index 9b23bd8433..58c05ac2a4 100644 --- a/src/pcache.c +++ b/src/pcache.c @@ -321,7 +321,7 @@ static SQLITE_NOINLINE PgHdr *pcacheFetchFinishWithInit( assert( pPage!=0 ); pPgHdr = (PgHdr*)pPage->pExtra; assert( pPgHdr->pPage==0 ); - memset(pPgHdr, 0, sizeof(PgHdr)); + memset(pPgHdr, 0, sizeof(PgHdr)); pPgHdr->pPage = pPage; pPgHdr->pData = pPage->pBuf; pPgHdr->pExtra = (void *)&pPgHdr[1]; @@ -345,7 +345,7 @@ PgHdr *sqlite3PcacheFetchFinish( ){ PgHdr *pPgHdr; - if( pPage==0 ) return 0; + assert( pPage!=0 ); pPgHdr = (PgHdr *)pPage->pExtra; if( !pPgHdr->pPage ){