]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Add the SQLITE_CONFIG_PCACHE_HDRSZ option for sqlite3_config().
authordrh <drh@noemail.net>
Tue, 4 Nov 2014 12:11:23 +0000 (12:11 +0000)
committerdrh <drh@noemail.net>
Tue, 4 Nov 2014 12:11:23 +0000 (12:11 +0000)
FossilOrigin-Name: 6eb03e62a34e8e0964175283587247b0212db604

manifest
manifest.uuid
src/btree.c
src/btree.h
src/main.c
src/pcache.c
src/pcache.h
src/pcache1.c
src/sqlite.h.in

index 8d217ecfe030fb135bf5c9f59f74ca68dc45e11f..2d1da1580d71fc22c6240a5759ed848a6e46a77b 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Updates\sto\sthe\ssqlite3_stmt_scanstatus()\sdocumentation.\s\sNo\schanges\sto\scode.
-D 2014-11-03T18:03:00.467
+C Add\sthe\sSQLITE_CONFIG_PCACHE_HDRSZ\soption\sfor\ssqlite3_config().
+D 2014-11-04T12:11:23.751
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in cf57f673d77606ab0f2d9627ca52a9ba1464146a
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -172,8 +172,8 @@ F src/auth.c b56c78ebe40a2110fd361379f7e8162d23f92240
 F src/backup.c 7f841396adfd47507ff670a471162d2bfcda3136
 F src/bitvec.c 19a4ba637bd85f8f63fc8c9bae5ade9fb05ec1cb
 F src/btmutex.c 49ca66250c7dfa844a4d4cb8272b87420d27d3a5
-F src/btree.c 61d96c2edacc5267fae6e477c24c774cd540d7f0
-F src/btree.h a79aa6a71e7f1055f01052b7f821bd1c2dce95c8
+F src/btree.c 3cc918768d100f0efea62404b8f4e779b8c94731
+F src/btree.h 49b408be9c1cd41249076898e0673711071205d8
 F src/btreeInt.h 026d0129724e8f265fdc60d44ec240cf5a4e6179
 F src/build.c 67bb05b1077e0cdaccb2e36bfcbe7a5df9ed31e8
 F src/callback.c 7b44ce59674338ad48b0e84e7b72f935ea4f68b0
@@ -194,7 +194,7 @@ F src/journal.c b4124532212b6952f42eb2c12fa3c25701d8ba8d
 F src/legacy.c ba1863ea58c4c840335a84ec276fc2b25e22bc4e
 F src/lempar.c 7274c97d24bb46631e504332ccd3bd1b37841770
 F src/loadext.c de741e66e5ddc1598d904d7289239696e40ed994
-F src/main.c 5f659bdb14cdba1c3b587b6ed09167c147e308a1
+F src/main.c 8903165064534858a79ae06615ea7f4b482ad482
 F src/malloc.c 3c3ac67969612493d435e14b6832793209afd2ec
 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645
 F src/mem1.c faf615aafd8be74a71494dfa027c113ea5c6615f
@@ -218,9 +218,9 @@ F src/os_win.h 09e751b20bbc107ffbd46e13555dc73576d88e21
 F src/pager.c 8d97b3633f098fef817656dcbf167ca904511d78
 F src/pager.h d1eee3c3f741be247ce6d82752a178515fc8578b
 F src/parse.y 5dfead8aed90cb0c7c1115898ee2266804daff45
-F src/pcache.c 4121a0571c18581ee9f82f086d5e2030051ebd6a
-F src/pcache.h 9b559127b83f84ff76d735c8262f04853be0c59a
-F src/pcache1.c e412cb585f777c840ddce0500eddc5c6043c2bb5
+F src/pcache.c ace1b67632deeaa84859b4c16c27711dfb7db3d4
+F src/pcache.h b44658c9c932d203510279439d891a2a83e12ba8
+F src/pcache1.c facbdd3ecc09c8f750089d941305694301328e98
 F src/pragma.c 3f3e959390a10c0131676f0e307acce372777e0f
 F src/prepare.c b7b7bf020bd4c962f7c8aed5a3c542c7dfe9f9c7
 F src/printf.c 9e75a6a0b55bf61cfff7d7e19d89834a1b938236
@@ -229,7 +229,7 @@ F src/resolve.c 4965007d6497b6a4d7a6d98751cc39712885f952
 F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e
 F src/select.c 428165951748151e87a15295b7357221433e311b
 F src/shell.c 282f8f5278e0c78eb442217531172ec9e1538796
-F src/sqlite.h.in 11f33a3e968a9637d6fa4ae879b83edd171ac88f
+F src/sqlite.h.in 915b5a955dd2f1d3c7e848f721af48ccc47b972b
 F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad
 F src/sqlite3ext.h 17d487c3c91b0b8c584a32fbeb393f6f795eea7d
 F src/sqliteInt.h 8f67ca79e957b8ece7453b8e320b6a996e1b4761
@@ -1211,7 +1211,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P ab3b0fc5760c6d428dbe1f974726a7d3526640bc
-R e3e372d3594a5227dc7ce2380d71aae3
+P d97c324eb1d870c994911c53fbf84205f4e3e7a1
+R 9efeed3832394f98added1ade80fb8e9
 U drh
-Z 7bcc3180ea33e48aa6d0e7855da7bfd4
+Z 388d5bd03930b5f393bf21b730c0228b
index 0611c8a12ec3db0546ccc0f4df1954c60d9e44d5..d3cdc0284b9b483d13161e970769f01e5dee5273 100644 (file)
@@ -1 +1 @@
-d97c324eb1d870c994911c53fbf84205f4e3e7a1
\ No newline at end of file
+6eb03e62a34e8e0964175283587247b0212db604
\ No newline at end of file
index 9300a6a54f5e295d9477e614b2d5224a0a180934..f815e85a6dcecdc80c0d6266b4b851d22422360a 100644 (file)
@@ -8965,3 +8965,8 @@ void sqlite3BtreeCursorHints(BtCursor *pCsr, unsigned int mask){
 int sqlite3BtreeIsReadonly(Btree *p){
   return (p->pBt->btsFlags & BTS_READ_ONLY)!=0;
 }
+
+/*
+** Return the size of the header added to each page by this module.
+*/
+int sqlite3HeaderSizeBtree(void){ return sizeof(MemPage); }
index 38abdca1a2ff00a5d4d4c365bf23ca60fa1e29d7..63337b194625f0b85ae929e504747681dd9abf1e 100644 (file)
@@ -196,6 +196,7 @@ void sqlite3BtreeClearCursor(BtCursor *);
 int sqlite3BtreeSetVersion(Btree *pBt, int iVersion);
 void sqlite3BtreeCursorHints(BtCursor *, unsigned int mask);
 int sqlite3BtreeIsReadonly(Btree *pBt);
+int sqlite3HeaderSizeBtree(void);
 
 #ifndef NDEBUG
 int sqlite3BtreeCursorIsValid(BtCursor*);
index 65a662ee5a1e7394937494d89a7b92505a821843..6a896b2a3db9dc5f682a788beb338fbf80203bda 100644 (file)
@@ -401,6 +401,15 @@ int sqlite3_config(int op, ...){
       sqlite3GlobalConfig.nPage = va_arg(ap, int);
       break;
     }
+    case SQLITE_CONFIG_PCACHE_HDRSZ: {
+      /* Return the total size of all headers added to each page
+      ** of the page cache */
+      *va_arg(ap, int*) = 
+          sqlite3HeaderSizeBtree() +
+          sqlite3HeaderSizePcache() +
+          sqlite3HeaderSizePcache1();
+      break;
+    }
 
     case SQLITE_CONFIG_PCACHE: {
       /* no-op */
index 191a9d00f41ded328642e71fa5da12138f38bc35..13551872d123d4cf7751558a2c8e6b1a782fcff8 100644 (file)
@@ -651,6 +651,13 @@ void sqlite3PcacheShrink(PCache *pCache){
   sqlite3GlobalConfig.pcache2.xShrink(pCache->pCache);
 }
 
+/*
+** Return the size of the header added by this middleware layer
+** in the page-cache hierarchy.
+*/
+int sqlite3HeaderSizePcache(void){ return sizeof(PgHdr); }
+
+
 #if defined(SQLITE_CHECK_PAGES) || defined(SQLITE_DEBUG)
 /*
 ** For all dirty pages currently in the cache, invoke the specified
index dd9bfc7451c308d3e2ced6f0aeb11b8633d196be..9ed62a88ff570b8f4a91f7d95d856a6ccb1df06a 100644 (file)
@@ -160,4 +160,8 @@ void sqlite3PcacheStats(int*,int*,int*,int*);
 
 void sqlite3PCacheSetDefault(void);
 
+/* Return the header size */
+int sqlite3HeaderSizePcache(void);
+int sqlite3HeaderSizePcache1(void);
+
 #endif /* _PCACHE_H_ */
index a8c3217382a10b170f017a2648a8759e0dd28b5f..cad41b1b73e309dcf9428570fd1fcc9a37adff58 100644 (file)
@@ -981,6 +981,11 @@ void sqlite3PCacheSetDefault(void){
   sqlite3_config(SQLITE_CONFIG_PCACHE2, &defaultMethods);
 }
 
+/*
+** Return the size of the header on each page of this PCACHE implementation.
+*/
+int sqlite3HeaderSizePcache1(void){ return sizeof(PgHdr1); }
+
 #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
 /*
 ** This function is called to free superfluous dynamically allocated memory
index 41cc43984614cc42dec99e991c5728174e470fe5..13373afe4a7e249dcbdee090de6226fa2ce6f095 100644 (file)
@@ -1559,28 +1559,30 @@ struct sqlite3_mem_methods {
 ** <dd> ^This option specifies a static memory buffer that SQLite can use for
 ** the database page cache with the default page cache implementation.  
 ** This configuration should not be used if an application-define page
-** cache implementation is loaded using the SQLITE_CONFIG_PCACHE2 option.
-** There are three arguments to this option: A pointer to 8-byte aligned
+** cache implementation is loaded using the [SQLITE_CONFIG_PCACHE2]
+** configuration option.
+** ^There are three arguments to this option: A pointer to 8-byte aligned
 ** memory, the size of each page buffer (sz), and the number of pages (N).
 ** The sz argument should be the size of the largest database page
-** (a power of two between 512 and 32768) plus a little extra for each
-** page header.  ^The page header size is 20 to 40 bytes depending on
-** the host architecture.  ^It is harmless, apart from the wasted memory,
-** to make sz a little too large.  The first
-** argument should point to an allocation of at least sz*N bytes of memory.
+** (a power of two between 512 and 32768) plus some extra bytes for each
+** page header.  ^The number of extra bytes needed by the page header
+** can be determined using the [SQLITE_CONFIG_PCACHE_HDRSZ] option 
+** to [sqlite3_config()].
+** ^It is harmless, apart from the wasted memory,
+** for the sz parameter to be larger than necessary.  The first
+** argument should pointer to an 8-byte aligned block of memory that
+** is at least sz*N bytes of memory, otherwise subsequent behavior is
+** undefined.
 ** ^SQLite will use the memory provided by the first argument to satisfy its
 ** memory needs for the first N pages that it adds to cache.  ^If additional
 ** page cache memory is needed beyond what is provided by this option, then
-** SQLite goes to [sqlite3_malloc()] for the additional storage space.
-** The pointer in the first argument must
-** be aligned to an 8-byte boundary or subsequent behavior of SQLite
-** will be undefined.</dd>
+** SQLite goes to [sqlite3_malloc()] for the additional storage space.</dd>
 **
 ** [[SQLITE_CONFIG_HEAP]] <dt>SQLITE_CONFIG_HEAP</dt>
 ** <dd> ^This option specifies a static memory buffer that SQLite will use
 ** for all of its dynamic memory allocation needs beyond those provided
 ** for by [SQLITE_CONFIG_SCRATCH] and [SQLITE_CONFIG_PAGECACHE].
-** There are three arguments: An 8-byte aligned pointer to the memory,
+** ^There are three arguments: An 8-byte aligned pointer to the memory,
 ** the number of bytes in the memory buffer, and the minimum allocation size.
 ** ^If the first pointer (the memory pointer) is NULL, then SQLite reverts
 ** to using its default memory allocator (the system malloc() implementation),
@@ -1728,6 +1730,15 @@ struct sqlite3_mem_methods {
 ** SQLITE_CONFIG_WIN32_HEAPSIZE takes a 32-bit unsigned integer value
 ** that specifies the maximum size of the created heap.
 ** </dl>
+**
+** [[SQLITE_CONFIG_PCACHE_HDRSZ]]
+** <dt>SQLITE_CONFIG_PCACHE_HDRSZ
+** <dd>^This option takes a single parameter which is a pointer to an integer
+** and writes into that integer the number of extra bytes per page required
+** for each page in [SQLITE_CONFIG_PAGECACHE].  The amount of
+** extra space required can change depending on the compiler,
+** target platform, and SQLite version.
+** </dl>
 */
 #define SQLITE_CONFIG_SINGLETHREAD  1  /* nil */
 #define SQLITE_CONFIG_MULTITHREAD   2  /* nil */
@@ -1752,6 +1763,7 @@ struct sqlite3_mem_methods {
 #define SQLITE_CONFIG_SQLLOG       21  /* xSqllog, void* */
 #define SQLITE_CONFIG_MMAP_SIZE    22  /* sqlite3_int64, sqlite3_int64 */
 #define SQLITE_CONFIG_WIN32_HEAPSIZE      23  /* int nByte */
+#define SQLITE_CONFIG_PCACHE_HDRSZ        24  /* int *psz */
 
 /*
 ** CAPI3REF: Database Connection Configuration Options