Omit the (undocumented) SQLITE_PCACHE_SEPARATE_HEADER compile-time option.

FossilOrigin-Name: 60947da687d525e72e62bcddcdf4c5c819818855074cc318c9ee656e83897aef
This commit is contained in:
drh 2022-08-09 14:28:54 +00:00
parent 6aafd74853
commit c8e9f6818b
5 changed files with 26 additions and 42 deletions

View File

@ -1,5 +1,5 @@
C Avoid\ssome\scases\sof\ssigned\sinteger\soverflow\sin\sfts5\sby\scasting\sto\sunsigned\svalues. C Omit\sthe\s(undocumented)\sSQLITE_PCACHE_SEPARATE_HEADER\scompile-time\soption.
D 2022-08-08T19:29:53.445 D 2022-08-09T14:28:54.231
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@ -517,7 +517,7 @@ F src/btreeInt.h 8ce1332edd89dfd2461d561ac10a0ab5601c8e06200cb5230596c3caaf54482
F src/build.c 33aec2b34dbc53c3da2ea8434fccbf3c17c35ba647c3193df598cce0e861355c F src/build.c 33aec2b34dbc53c3da2ea8434fccbf3c17c35ba647c3193df598cce0e861355c
F src/callback.c 4c19af69835787bfe790ac560f3071a824eb629f34e41f97b52ce5235c77de1c F src/callback.c 4c19af69835787bfe790ac560f3071a824eb629f34e41f97b52ce5235c77de1c
F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e
F src/ctime.c 026dbdcdbd8c3cde98a88483ee88310ff43150ab164ad768f12cc700a11495ad F src/ctime.c 93e4b5f4faf6d3f688988a116773259a4fbfb4ddac0e9bf9d0ae0429390c2543
F src/date.c 94ce83b4cd848a387680a5f920c9018c16655db778c4d36525af0a0f34679ac5 F src/date.c 94ce83b4cd848a387680a5f920c9018c16655db778c4d36525af0a0f34679ac5
F src/dbpage.c 5808e91bc27fa3981b028000f8fadfdc10ce9e59a34ce7dc4e035a69be3906ec F src/dbpage.c 5808e91bc27fa3981b028000f8fadfdc10ce9e59a34ce7dc4e035a69be3906ec
F src/dbstat.c 861e08690fcb0f2ee1165eff0060ea8d4f3e2ea10f80dab7d32ad70443a6ff2d F src/dbstat.c 861e08690fcb0f2ee1165eff0060ea8d4f3e2ea10f80dab7d32ad70443a6ff2d
@ -563,7 +563,7 @@ F src/pager.h f82e9844166e1585f5786837ddc7709966138ced17f568c16af7ccf946c2baa3
F src/parse.y 8e67d820030d2655b9942ffe61c1e7e6b96cea2f2f72183533299393907d0564 F src/parse.y 8e67d820030d2655b9942ffe61c1e7e6b96cea2f2f72183533299393907d0564
F src/pcache.c 084e638432c610f95aea72b8509f0845d2791293f39d1b82f0c0a7e089c3bb6b F src/pcache.c 084e638432c610f95aea72b8509f0845d2791293f39d1b82f0c0a7e089c3bb6b
F src/pcache.h 4f87acd914cef5016fae3030343540d75f5b85a1877eed1a2a19b9f284248586 F src/pcache.h 4f87acd914cef5016fae3030343540d75f5b85a1877eed1a2a19b9f284248586
F src/pcache1.c 54881292a9a5db202b2c0ac541c5e3ef9a5e8c4f1c1383adb2601d5499a60e65 F src/pcache1.c 0b4245cd4964e635f2630908c2533cd8e9da7af3ca592e23ae8730aa25ae5eb9
F src/pragma.c 6637d624c37a8909d3edfa9d7cf694d79b49d2a0827d8c52ef15dceb641783fa F src/pragma.c 6637d624c37a8909d3edfa9d7cf694d79b49d2a0827d8c52ef15dceb641783fa
F src/pragma.h e690a356c18e98414d2e870ea791c1be1545a714ba623719deb63f7f226d8bb7 F src/pragma.h e690a356c18e98414d2e870ea791c1be1545a714ba623719deb63f7f226d8bb7
F src/prepare.c c62820c15dcb63013519c8e41d9f928d7478672cc902cfd0581c733c271dbf45 F src/prepare.c c62820c15dcb63013519c8e41d9f928d7478672cc902cfd0581c733c271dbf45
@ -1909,7 +1909,7 @@ F tool/max-limits.c cbb635fbb37ae4d05f240bfb5b5270bb63c54439
F tool/merge-test.tcl de76b62f2de2a92d4c1ca4f976bce0aea6899e0229e250479b229b2a1914b176 F tool/merge-test.tcl de76b62f2de2a92d4c1ca4f976bce0aea6899e0229e250479b229b2a1914b176
F tool/mkautoconfamal.sh f62353eb6c06ab264da027fd4507d09914433dbdcab9cb011cdc18016f1ab3b8 F tool/mkautoconfamal.sh f62353eb6c06ab264da027fd4507d09914433dbdcab9cb011cdc18016f1ab3b8
F tool/mkccode.tcl 86463e68ce9c15d3041610fedd285ce32a5cf7a58fc88b3202b8b76837650dbe x F tool/mkccode.tcl 86463e68ce9c15d3041610fedd285ce32a5cf7a58fc88b3202b8b76837650dbe x
F tool/mkctimec.tcl ac96a74f5e6d9dac672d5229f79c583d3357a50e7d098e473e6b2ce2f8ae1704 x F tool/mkctimec.tcl 8f472681f6041cf0ec26a1799feda39e55370614a6090d66fa5044f9f52d22c6 x
F tool/mkkeywordhash.c 35bfc41adacc4aa6ef6fca7fd0c63e0ec0534b78daf4d0cfdebe398216bbffc3 F tool/mkkeywordhash.c 35bfc41adacc4aa6ef6fca7fd0c63e0ec0534b78daf4d0cfdebe398216bbffc3
F tool/mkmsvcmin.tcl 6ecab9fe22c2c8de4d82d4c46797bda3d2deac8e763885f5a38d0c44a895ab33 F tool/mkmsvcmin.tcl 6ecab9fe22c2c8de4d82d4c46797bda3d2deac8e763885f5a38d0c44a895ab33
F tool/mkopcodec.tcl 33d20791e191df43209b77d37f0ff0904620b28465cca6990cf8d60da61a07ef F tool/mkopcodec.tcl 33d20791e191df43209b77d37f0ff0904620b28465cca6990cf8d60da61a07ef
@ -1982,8 +1982,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P 3518cd7cb1feeefc3963da72c2d258d81d8914f1e1f427da28a00b6228cf126c P 46a78c8c0ed518c4521e6e0bdebeb065bab07076abc444775002e7f4361d2242
R ee3441acc635032c89c4a495f8aff56d R d8bef198132a525587d2454d35cbc1ca
U dan U drh
Z 869f3966f913fbed35d61b23d360896d Z a9046e25d51003cb689d3e1458ccf6d6
# Remove this line to create a well-formed Fossil manifest. # Remove this line to create a well-formed Fossil manifest.

View File

@ -1 +1 @@
46a78c8c0ed518c4521e6e0bdebeb065bab07076abc444775002e7f4361d2242 60947da687d525e72e62bcddcdf4c5c819818855074cc318c9ee656e83897aef

View File

@ -683,9 +683,6 @@ static const char * const sqlite3azCompileOpt[] = {
#ifdef SQLITE_OMIT_XFER_OPT #ifdef SQLITE_OMIT_XFER_OPT
"OMIT_XFER_OPT", "OMIT_XFER_OPT",
#endif #endif
#ifdef SQLITE_PCACHE_SEPARATE_HEADER
"PCACHE_SEPARATE_HEADER",
#endif
#ifdef SQLITE_PERFORMANCE_TRACE #ifdef SQLITE_PERFORMANCE_TRACE
"PERFORMANCE_TRACE", "PERFORMANCE_TRACE",
#endif #endif

View File

@ -39,12 +39,13 @@
** size can vary according to architecture, compile-time options, and ** size can vary according to architecture, compile-time options, and
** SQLite library version number. ** SQLite library version number.
** **
** If SQLITE_PCACHE_SEPARATE_HEADER is defined, then the extension is obtained ** Historical note: It used to be that if the SQLITE_PCACHE_SEPARATE_HEADER
** using a separate memory allocation from the database page content. This ** was defined, then the page content would be held in a separate memory
** seeks to overcome the "clownshoe" problem (also called "internal ** allocation from the PgHdr1. This was intended to avoid clownshoe memory
** fragmentation" in academic literature) of allocating a few bytes more ** allocations. However, the btree layer needs a small (16-byte) overrun
** than a power of two with the memory allocator rounding up to the next ** area after the page content buffer. The header serves as that overrun
** power of two, and leaving the rounded-up space unused. ** area. Therefore SQLITE_PCACHE_SEPARATE_HEADER was discontinued to avoid
** any possibility of a memory error.
** **
** This module tracks pointers to PgHdr1 objects. Only pcache.c communicates ** This module tracks pointers to PgHdr1 objects. Only pcache.c communicates
** with this module. Information is passed back and forth as PgHdr1 pointers. ** with this module. Information is passed back and forth as PgHdr1 pointers.
@ -89,11 +90,16 @@ typedef struct PGroup PGroup;
/* /*
** Each cache entry is represented by an instance of the following ** Each cache entry is represented by an instance of the following
** structure. Unless SQLITE_PCACHE_SEPARATE_HEADER is defined, a buffer of ** structure. A buffer of PgHdr1.pCache->szPage bytes is allocated
** PgHdr1.pCache->szPage bytes is allocated directly before this structure ** directly before this structure and is used to cache the page content.
** in memory.
** **
** Note: Variables isBulkLocal and isAnchor were once type "u8". That works, ** When reading a corrupt database file, it is possible that SQLite might
** read a few bytes (no more than 16 bytes) past the end of the page buffer.
** It will only read past the end of the page buffer, never write. This
** object is positioned immediately after the page buffer to serve as an
** overrun area, so that overreads are harmless.
**
** Variables isBulkLocal and isAnchor were once type "u8". That works,
** but causes a 2-byte gap in the structure for most architectures (since ** but causes a 2-byte gap in the structure for most architectures (since
** pointers must be either 4 or 8-byte aligned). As this structure is located ** pointers must be either 4 or 8-byte aligned). As this structure is located
** in memory directly after the associated page data, if the database is ** in memory directly after the associated page data, if the database is
@ -438,25 +444,13 @@ static PgHdr1 *pcache1AllocPage(PCache1 *pCache, int benignMalloc){
pcache1LeaveMutex(pCache->pGroup); pcache1LeaveMutex(pCache->pGroup);
#endif #endif
if( benignMalloc ){ sqlite3BeginBenignMalloc(); } if( benignMalloc ){ sqlite3BeginBenignMalloc(); }
#ifdef SQLITE_PCACHE_SEPARATE_HEADER
pPg = pcache1Alloc(pCache->szPage);
p = sqlite3Malloc(sizeof(PgHdr1) + pCache->szExtra);
if( !pPg || !p ){
pcache1Free(pPg);
sqlite3_free(p);
pPg = 0;
}
#else
pPg = pcache1Alloc(pCache->szAlloc); pPg = pcache1Alloc(pCache->szAlloc);
#endif
if( benignMalloc ){ sqlite3EndBenignMalloc(); } if( benignMalloc ){ sqlite3EndBenignMalloc(); }
#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
pcache1EnterMutex(pCache->pGroup); pcache1EnterMutex(pCache->pGroup);
#endif #endif
if( pPg==0 ) return 0; if( pPg==0 ) return 0;
#ifndef SQLITE_PCACHE_SEPARATE_HEADER
p = (PgHdr1 *)&((u8 *)pPg)[pCache->szPage]; p = (PgHdr1 *)&((u8 *)pPg)[pCache->szPage];
#endif
p->page.pBuf = pPg; p->page.pBuf = pPg;
p->page.pExtra = &p[1]; p->page.pExtra = &p[1];
p->isBulkLocal = 0; p->isBulkLocal = 0;
@ -480,9 +474,6 @@ static void pcache1FreePage(PgHdr1 *p){
pCache->pFree = p; pCache->pFree = p;
}else{ }else{
pcache1Free(p->page.pBuf); pcache1Free(p->page.pBuf);
#ifdef SQLITE_PCACHE_SEPARATE_HEADER
sqlite3_free(p);
#endif
} }
(*pCache->pnPurgeable)--; (*pCache->pnPurgeable)--;
} }
@ -1246,9 +1237,6 @@ int sqlite3PcacheReleaseMemory(int nReq){
&& p->isAnchor==0 && p->isAnchor==0
){ ){
nFree += pcache1MemSize(p->page.pBuf); nFree += pcache1MemSize(p->page.pBuf);
#ifdef SQLITE_PCACHE_SEPARATE_HEADER
nFree += sqlite3MemSize(p);
#endif
assert( PAGE_IS_UNPINNED(p) ); assert( PAGE_IS_UNPINNED(p) );
pcache1PinPage(p); pcache1PinPage(p);
pcache1RemoveFromHash(p, 1); pcache1RemoveFromHash(p, 1);

View File

@ -254,7 +254,6 @@ set boolean_defnil_options {
SQLITE_OMIT_WAL SQLITE_OMIT_WAL
SQLITE_OMIT_WSD SQLITE_OMIT_WSD
SQLITE_OMIT_XFER_OPT SQLITE_OMIT_XFER_OPT
SQLITE_PCACHE_SEPARATE_HEADER
SQLITE_PERFORMANCE_TRACE SQLITE_PERFORMANCE_TRACE
SQLITE_PREFER_PROXY_LOCKING SQLITE_PREFER_PROXY_LOCKING
SQLITE_PROXY_DEBUG SQLITE_PROXY_DEBUG