From: drh Date: Sat, 4 Jul 2015 18:15:04 +0000 (+0000) Subject: Preserve the number of requested PAGECACHE pages even if the memory pointer X-Git-Tag: version-3.8.11~57 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=01c5c00c1299dd4c7933cc3df231c04183aedc47;p=thirdparty%2Fsqlite.git Preserve the number of requested PAGECACHE pages even if the memory pointer or size is zero. Enhance the pcache1.c header comment to explain the memory layout of a page cache line. FossilOrigin-Name: dacb2a615ce1c0573baf4518000454038745cf2a --- diff --git a/manifest b/manifest index 52014a9ab7..380f99bcb1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sproblem\sin\sthe\sfts5\sintegrity-check. -D 2015-07-04T15:35:02.267 +C Preserve\sthe\snumber\sof\srequested\sPAGECACHE\spages\seven\sif\sthe\smemory\spointer\nor\ssize\sis\szero.\s\sEnhance\sthe\spcache1.c\sheader\scomment\sto\sexplain\sthe\smemory\nlayout\sof\sa\spage\scache\sline. +D 2015-07-04T18:15:04.326 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 017bf0511d1b2dd1db5e16488fbf75a17b526cbc F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -293,7 +293,7 @@ F src/legacy.c ba1863ea58c4c840335a84ec276fc2b25e22bc4e F src/lempar.c 92bafa308607dd985ca389a788cd9e0a2b608712 F src/loadext.c e722f4b832f923744788365df5fb8515c0bc8a47 F src/main.c 92d79bfa1a36c7c554700bb58eb8327abff1ac5c -F src/malloc.c 9be4e645f2fb411e5a04cf97e91f68b4faa6dc81 +F src/malloc.c 19461e159bccf0e2cf06a50e867963d0a7b124a8 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c abe6ee469b6c5a35c7f22bfeb9c9bac664a1c987 F src/mem2.c f1940d9e91948dd6a908fbb9ce3835c36b5d83c3 @@ -319,7 +319,7 @@ F src/pager.h 6d435f563b3f7fcae4b84433b76a6ac2730036e2 F src/parse.y 6d60dda8f8d418b6dc034f1fbccd816c459983a8 F src/pcache.c cde06aa50962595e412d497e22fd2e07878ba1f0 F src/pcache.h 9968603796240cdf83da7e7bef76edf90619cea9 -F src/pcache1.c 9ec20f98f50ed7415019303ae9bd3745d4b7bd9b +F src/pcache1.c b800e90896640bb0d1b0f6baa34fb059ca3b8b2e F src/pragma.c c1f4d012ea9f6b1ce52d341b2cd0ad72d560afd7 F src/pragma.h b8632d7cdda7b25323fa580e3e558a4f0d4502cc F src/prepare.c 82e5db1013846a819f198336fed72c44c974e7b1 @@ -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 743bf1f184be316971f2e9c651bcf573bde8654a -R 9bf7551534e5c2a541b49f913ee30aa3 -U dan -Z 59b496d519385223221d6df6daef9f3a +P 4e473559c9bdcf4d0b823e995a3642cd50ebd337 +R 3bd4765a55a11bf2fbafbabfd8169c43 +U drh +Z 0199ebd97104f84a289dac04b3e8dc79 diff --git a/manifest.uuid b/manifest.uuid index 0ee45a678c..67c01f1a49 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4e473559c9bdcf4d0b823e995a3642cd50ebd337 \ No newline at end of file +dacb2a615ce1c0573baf4518000454038745cf2a \ No newline at end of file diff --git a/src/malloc.c b/src/malloc.c index 97b9cd5778..1e77734ecb 100644 --- a/src/malloc.c +++ b/src/malloc.c @@ -193,10 +193,9 @@ int sqlite3MallocInit(void){ sqlite3GlobalConfig.nScratch = 0; } if( sqlite3GlobalConfig.pPage==0 || sqlite3GlobalConfig.szPage<512 - || sqlite3GlobalConfig.nPage<1 ){ + || sqlite3GlobalConfig.nPage<=0 ){ sqlite3GlobalConfig.pPage = 0; sqlite3GlobalConfig.szPage = 0; - sqlite3GlobalConfig.nPage = 0; } rc = sqlite3GlobalConfig.m.xInit(sqlite3GlobalConfig.m.pAppData); if( rc!=SQLITE_OK ) memset(&mem0, 0, sizeof(mem0)); diff --git a/src/pcache1.c b/src/pcache1.c index 7185ab441b..797354bd75 100644 --- a/src/pcache1.c +++ b/src/pcache1.c @@ -15,6 +15,41 @@ ** of the SQLITE_CONFIG_PAGECACHE and sqlite3_release_memory() features. ** If the default page cache implementation is overridden, then neither of ** these two features are available. +** +** A Page cache line looks like this: +** +** ------------------------------------------------------------- +** | database page content | PgHdr1 | MemPage | PgHdr | +** ------------------------------------------------------------- +** +** The database page content is up front (so that buffer overreads tend to +** flow harmlessly into the PgHdr1, MemPage, and PgHdr extensions). MemPage +** is the extension added by the btree.c module containing information such +** as the database page number and how that database page is used. PgHdr +** is added by the pcache.c layer and contains information used to keep track +** of which pages are "dirty". PgHdr1 is an extension added by this +** module (pcache1.c). The PgHdr1 header is a subclass of sqlite3_pcache_page. +** PgHdr1 contains information needed to look up a page by its page number. +** The superclass sqlite3_pcache_page.pBuf points to the start of the +** database page content and sqlite3_pcache_page.pExtra points to PgHdr. +** +** The size of the extension (MemPage+PgHdr+PgHdr1) can be determined at +** runtime using sqlite3_config(SQLITE_CONFIG_PCACHE_HDRSZ, &size). The +** sizes of the extensions sum to 272 bytes on x64 for 3.8.10, but this +** size can vary according to architecture, compile-time options, and +** SQLite library version number. +** +** If SQLITE_PCACHE_SEPARATE_HEADER is defined, then the extension is obtained +** using a separate memory allocation from the database page content. This +** seeks to overcome the "clownfoot" problem of allocating a few bytes more +** than a power of two with the memory allocator rounding up to the next +** power of two, and leaving the rounded-up space unused. +** +** This module tracks pointers to PgHdr1 objects. Only pcache.c communicates +** with this module. Information is passed back and forth as PgHdr1 pointers. +** +** The pcache.c and pager.c modules deal pointers to PgHdr objects. +** The btree.c module deals with pointers to MemPage objects. */ #include "sqliteInt.h"