]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Memory-mapped I/O is now on by default. The "PRAGMA mmap_limit(N)" can be
authordrh <drh@noemail.net>
Mon, 25 Mar 2013 23:09:28 +0000 (23:09 +0000)
committerdrh <drh@noemail.net>
Mon, 25 Mar 2013 23:09:28 +0000 (23:09 +0000)
used to issue a hint to the VFS to limit mmap space to N bytes.  The VFS
is free to ignore that hint if desired.  However, if "PRAGMA mmap_limit(0)"
is used, xFetch is never called.

FossilOrigin-Name: 1b37c4effdd03aa2ea938a71b4f22ed27391689b

18 files changed:
manifest
manifest.uuid
src/btree.c
src/btree.h
src/os_unix.c
src/pager.c
src/pager.h
src/pragma.c
src/sqlite.h.in
src/sqliteInt.h
src/sqliteLimit.h
test/dbstatus2.test
test/incrblob.test
test/mmap1.test
test/permutations.test
test/speed1p.test
test/sysfault.test
test/wal5.test

index b0a5aaeb5ff73d19b4a2feeef7c5c8a6d3d23eb0..65993928dd9e2429180840cbf8e6eaf680a5b3ca 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Add\smunmap\sand\smremap\sto\sthe\sset\sof\sos\sinterfaces\sthat\scan\sbe\soverloaded\nin\sos_unix.c.
-D 2013-03-25T20:50:25.204
+C Memory-mapped\sI/O\sis\snow\son\sby\sdefault.\s\sThe\s"PRAGMA\smmap_limit(N)"\scan\sbe\nused\sto\sissue\sa\shint\sto\sthe\sVFS\sto\slimit\smmap\sspace\sto\sN\sbytes.\s\sThe\sVFS\nis\sfree\sto\signore\sthat\shint\sif\sdesired.\s\sHowever,\sif\s"PRAGMA\smmap_limit(0)"\nis\sused,\sxFetch\sis\snever\scalled.
+D 2013-03-25T23:09:28.646
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in df3e48659d80e1b7765785d8d66c86b320f72cc7
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -121,8 +121,8 @@ F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34
 F src/backup.c b2cac9f7993f3f9588827b824b1501d0c820fa68
 F src/bitvec.c 19a4ba637bd85f8f63fc8c9bae5ade9fb05ec1cb
 F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7
-F src/btree.c ef238f2d88c6072cc0d6cff33b72c2a9044a15e4
-F src/btree.h d3259057a38494c4c4358e377032158c762e3d8b
+F src/btree.c 771f0391556317de19e02c9533b256e8299dd59b
+F src/btree.h d9490cd37aaeb530a41b07f06e1262950b1be916
 F src/btreeInt.h eecc84f02375b2bb7a44abbcbbe3747dde73edb2
 F src/build.c 083da8466fd7e481cb8bd5264398f537507f6176
 F src/callback.c d7e46f40c3cf53c43550b7da7a1d0479910b62cc
@@ -160,15 +160,15 @@ F src/notify.c 976dd0f6171d4588e89e874fcc765e92914b6d30
 F src/os.c 809d0707cec693e1b9b376ab229271ad74c3d35d
 F src/os.h ae08bcc5f6ec6b339f4a2adf3931bb88cc14c3e4
 F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04
-F src/os_unix.c 6b3f972a8b515ce151d1d075080b10d52adbfbd6
+F src/os_unix.c 57306f1d2a2d783dae4365446b9f9a5da8958559
 F src/os_win.c e4f17ddf79f2a9373e33ed70565e765d65324589
-F src/pager.c 4e1b55e7a50db0466b06f8ec114799b432c18131
-F src/pager.h 241d72dc0905df042da165f086d03505cb0bb50c
+F src/pager.c c532d51ccc74de8551a28eb932f3b1a1034017d3
+F src/pager.h 5cb78b8e1adfd5451e600be7719f5a99d87ac3b1
 F src/parse.y 5d5e12772845805fdfeb889163516b84fbb9ae95
 F src/pcache.c f8043b433a57aba85384a531e3937a804432a346
 F src/pcache.h a5e4f5d9f5d592051d91212c5949517971ae6222
 F src/pcache1.c 9fd22671c270b35131ef480bbc00392b8b5f8ab9
-F src/pragma.c 86c8088ac6a12d3f3be5f7394542651f03fa9a38
+F src/pragma.c 8875d32d54530300e6aa31a9d5426b2088a69b12
 F src/prepare.c 310eaff1ee5f3c700b3545afb095cfe9346efc3a
 F src/printf.c 4a9f882f1c1787a8b494a2987765acf9d97ac21f
 F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50
@@ -176,11 +176,11 @@ F src/resolve.c 9079da7d59aed2bb14ec8315bc7f720dd85b5b65
 F src/rowset.c 64655f1a627c9c212d9ab497899e7424a34222e0
 F src/select.c 01540bcd3df3c8f1187158e77986028b1c667258
 F src/shell.c 7c41bfcd9e5bf9d96b9215f79b03a5b2b44a3bca
-F src/sqlite.h.in 457eb0ba9fbc331281dca53182c90035b087527f
+F src/sqlite.h.in 921ba42ec3531fe8cf021492ffd781b161383f1b
 F src/sqlite3.rc fea433eb0a59f4c9393c8e6d76a6e2596b1fe0c0
 F src/sqlite3ext.h 7183ab832e23db0f934494f16928da127a571d75
-F src/sqliteInt.h 2c3d830ae78b046ebf939c905c023610e43c2796
-F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d
+F src/sqliteInt.h 0f8f05ee4db4ba9120b38f7a3992b325698f6e8a
+F src/sqliteLimit.h 83d0cd0ce3050a80930406d3c7aecb48c1ccdfc5
 F src/status.c bedc37ec1a6bb9399944024d63f4c769971955a9
 F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e
 F src/tclsqlite.c 9a716c737590d2f129d71c8fc7065e5aba0e7222
@@ -369,7 +369,7 @@ F test/cse.test 277350a26264495e86b1785f34d2d0c8600e021c
 F test/ctime.test 7bd009071e242aac4f18521581536b652b789a47
 F test/date.test f3228180c87bbe5d39c9397bf001c0095c3821b9
 F test/dbstatus.test 207e5b63fcb7b9c3bb8e1fdf38ebd4654ad0e54b
-F test/dbstatus2.test 10418e62b3db5dca070f0c3eef3ea13946f339c2
+F test/dbstatus2.test f329941d5f4a8bc0ba6ec5735897ef0cf34e2f5f
 F test/default.test 6faf23ccb300114924353007795aa9a8ec0aa9dc
 F test/delete.test a065b05d2ebf60fd16639c579a4adfb7c381c701
 F test/delete2.test 3a03f2cca1f9a67ec469915cb8babd6485db43fa
@@ -526,7 +526,7 @@ F test/in2.test 5d4c61d17493c832f7d2d32bef785119e87bde75
 F test/in3.test 3cbf58c87f4052cee3a58b37b6389777505aa0c0
 F test/in4.test 64f3cc1acde1b9161ccdd8e5bde3daefdb5b2617
 F test/in5.test 99f9a40af01711b06d2d614ecfe96129f334fba3
-F test/incrblob.test e81846d214f3637622620fbde7cd526781cfe328
+F test/incrblob.test 2100cb8964e4a106e5ca9bf80e2c5c3e8be33f77
 F test/incrblob2.test edc3a96e557bd61fb39acc8d2edd43371fbbaa19
 F test/incrblob3.test aedbb35ea1b6450c33b98f2b6ed98e5020be8dc7
 F test/incrblob4.test 09be37d3dd996a31ea6993bba7837ece549414a8
@@ -630,7 +630,7 @@ F test/misc5.test 528468b26d03303b1f047146e5eefc941b9069f5
 F test/misc6.test 953cc693924d88e6117aeba16f46f0bf5abede91
 F test/misc7.test dd82ec9250b89178b96cd28b2aca70639d21e5b3
 F test/misuse.test ba4fb5d1a6101d1c171ea38b3c613d0661c83054
-F test/mmap1.test e3391ef6c069e5f5733b8339652ce37fd97e3487
+F test/mmap1.test 9fb71daaca72f66fcc7a3b3a37fc3db99988b57a
 F test/multiplex.test e08cc7177bd6d85990ee1d71100bb6c684c02256
 F test/multiplex2.test 580ca5817c7edbe4cc68fa150609c9473393003a
 F test/multiplex3.test d228f59eac91839a977eac19f21d053f03e4d101
@@ -658,7 +658,7 @@ F test/pageropt.test 290cd59782b1890f02bb33795571facfc5ccac43
 F test/pagesize.test 1dd51367e752e742f58e861e65ed7390603827a0
 F test/pcache.test 065aa286e722ab24f2e51792c1f093bf60656b16
 F test/pcache2.test a83efe2dec0d392f814bfc998def1d1833942025
-F test/permutations.test 5b5397f33b9d129b734b9c57a5091ad494e025c5
+F test/permutations.test d298a74abae42b72b3640dc5505d19d8a3eddc9e
 F test/pragma.test 60d29cd3d8098a2c20bf4c072810f99e3bf2757a
 F test/pragma2.test 3a55f82b954242c642f8342b17dffc8b47472947
 F test/printf.test ec9870c4dce8686a37818e0bf1aba6e6a1863552
@@ -731,7 +731,7 @@ F test/softheap1.test c16709a16ad79fa43b32929b2e623d1d117ccf53
 F test/sort.test 0e4456e729e5a92a625907c63dcdedfbe72c5dc5
 F test/speed1.test f2974a91d79f58507ada01864c0e323093065452
 F test/speed1p.explain d841e650a04728b39e6740296b852dccdca9b2cb
-F test/speed1p.test 9912e8f915f1de2c82fc019a63920bf9dcfc69f7
+F test/speed1p.test c4a469f29f135f4d76c55b1f2a52f36e209466cc
 F test/speed2.test 53177056baf6556dcbdcf032bbdfc41c1aa74ded
 F test/speed3.test d32043614c08c53eafdc80f33191d5bd9b920523
 F test/speed4.test abc0ad3399dcf9703abed2fff8705e4f8e416715
@@ -748,7 +748,7 @@ F test/substr.test 18f57c4ca8a598805c4d64e304c418734d843c1a
 F test/superlock.test 1cde669f68d2dd37d6c9bd35eee1d95491ae3fc2
 F test/sync.test a34cd43e98b7fb84eabbf38f7ed8f7349b3f3d85
 F test/syscall.test a653783d985108c4912cc64d341ffbbb55ad2806
-F test/sysfault.test 3258d6c8213b44f2669994d798a5eb5327b40146
+F test/sysfault.test 503f72712b2b21cb80dc9899e53c2e39484d0313
 F test/table.test a59d985ca366e39b17b175f387f9d5db5a18d4e2
 F test/tableapi.test 2674633fa95d80da917571ebdd759a14d9819126
 F test/tclsqlite.test 37a61c2da7e3bfe3b8c1a2867199f6b860df5d43
@@ -955,7 +955,7 @@ F test/wal.test 5baa9a0e682c0394012aa9a06a3d06cf92655fbf
 F test/wal2.test d4b470f13c87f6d8268b004380afa04c3c67cb90
 F test/wal3.test b22eb662bcbc148c5f6d956eaf94b047f7afe9c0
 F test/wal4.test 4744e155cd6299c6bd99d3eab1c82f77db9cdb3c
-F test/wal5.test 091bf7500e97087f1a87b346c8707e93f42d4f80
+F test/wal5.test f4d0aee6a2cf09e326ed2459011d396b4fdf661a
 F test/wal6.test 2e3bc767d9c2ce35c47106148d43fcbd072a93b3
 F test/wal7.test 2ae8f427d240099cc4b2dfef63cff44e2a68a1bd
 F test/wal8.test b3ee739fe8f7586aaebdc2367f477ebcf3e3b034
@@ -1040,7 +1040,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381
 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac
-P 431aecc8600c29c203546e48d256510510238887
-R 420b4ff666854b5074068c14722ea276
+P 8776047bd776bbf266eb9c3b56683badb84ae73e
+R 1fba4ef23570acddc66df7d627b1cb5f
 U drh
-Z feb03effee9a1e5215de46a6338d0c52
+Z c62aae7ee656f659e8aebd3681920a9a
index 5b13e95f757de3abe54ddc4fb64eb1c4e04d96e8..8e0647f65170ed031e3d5055ddd4ab066ae2785d 100644 (file)
@@ -1 +1 @@
-8776047bd776bbf266eb9c3b56683badb84ae73e
\ No newline at end of file
+1b37c4effdd03aa2ea938a71b4f22ed27391689b
\ No newline at end of file
index 59970ded7fcb763480fe673aef12d91f565eaa97..04cc20d5c5ef6c634affd6f11b2b812bdfa533ee 100644 (file)
@@ -2134,11 +2134,11 @@ int sqlite3BtreeSetCacheSize(Btree *p, int mxPage){
 ** Change the limit on the amount of the database file that may be
 ** memory mapped.
 */
-int sqlite3BtreeSetMmapSize(Btree *p, int nMap){
+int sqlite3BtreeSetMmapLimit(Btree *p, sqlite3_int64 mxMmap){
   BtShared *pBt = p->pBt;
   assert( sqlite3_mutex_held(p->db->mutex) );
   sqlite3BtreeEnter(p);
-  sqlite3PagerSetMmapsize(pBt->pPager, nMap);
+  sqlite3PagerSetMmapLimit(pBt->pPager, mxMmap);
   sqlite3BtreeLeave(p);
   return SQLITE_OK;
 }
index f2cca2fc710a2073bdb8126299075dd44af1c54f..23f6ad7068fb37c7989e990f7c946a6c3f565f63 100644 (file)
@@ -63,7 +63,7 @@ int sqlite3BtreeOpen(
 
 int sqlite3BtreeClose(Btree*);
 int sqlite3BtreeSetCacheSize(Btree*,int);
-int sqlite3BtreeSetMmapSize(Btree*, int);
+int sqlite3BtreeSetMmapLimit(Btree*,sqlite3_int64);
 int sqlite3BtreeSetSafetyLevel(Btree*,int,int,int);
 int sqlite3BtreeSyncDisabled(Btree*);
 int sqlite3BtreeSetPageSize(Btree *p, int nPagesize, int nReserve, int eFix);
index 625f4134062d0eb634093d1ccdd091bfed0dbc19..8a8516bcda19aca3afa09d5a86c72b294b04a8e0 100644 (file)
@@ -225,6 +225,11 @@ struct unixFile {
   const char *zPath;                  /* Name of the file */
   unixShm *pShm;                      /* Shared memory segment information */
   int szChunk;                        /* Configured by FCNTL_CHUNK_SIZE */
+  int nFetchOut;                      /* Number of outstanding xFetch refs */
+  sqlite3_int64 mmapSize;             /* Usable size of mapping at pMapRegion */
+  sqlite3_int64 mmapOrigsize;         /* Actual size of mapping at pMapRegion */
+  sqlite3_int64 mmapLimit;            /* Configured FCNTL_MMAP_LIMIT value */
+  void *pMapRegion;                   /* Memory mapped region */
 #ifdef __QNXNTO__
   int sectorSize;                     /* Device sector size */
   int deviceCharacteristics;          /* Precomputed device characteristics */
@@ -251,11 +256,6 @@ struct unixFile {
   unsigned char inNormalWrite;   /* True if in a normal write operation */
 
 #endif
-  sqlite3_int64 mmapSize;         /* Usable size of mapping at pMapRegion */
-  sqlite3_int64 mmapOrigsize;     /* Actual size of mapping at pMapRegion */
-  sqlite3_int64 mmapLimit;        /* Configured FCNTL_MMAP_SIZE value */
-  void *pMapRegion;               /* Memory mapped region */
-  int nFetchOut;                  /* Number of outstanding xFetch refs */
 
 #ifdef SQLITE_TEST
   /* In test mode, increase the size of this structure a bit so that 
@@ -3699,7 +3699,7 @@ static int unixFileControl(sqlite3_file *id, int op, void *pArg){
       }
       return SQLITE_OK;
     }
-    case SQLITE_FCNTL_MMAP_SIZE: {
+    case SQLITE_FCNTL_MMAP_LIMIT: {
       pFile->mmapLimit = *(i64*)pArg;
       return SQLITE_OK;
     }
@@ -4528,7 +4528,7 @@ static void unixUnmapfile(unixFile *pFd){
 ** the mapping to create. Otherwise, if nByte is less than zero, then the 
 ** requested size is the size of the file on disk. The actual size of the
 ** created mapping is either the requested size or the value configured 
-** using SQLITE_FCNTL_MMAP_SIZE, whichever is smaller.
+** using SQLITE_FCNTL_MMAP_LIMIT, whichever is smaller.
 **
 ** SQLITE_OK is returned if no error occurs (even if the mapping is not
 ** recreated as a result of outstanding references) or an SQLite error
@@ -4969,6 +4969,7 @@ static int fillInUnixFile(
   pNew->pVfs = pVfs;
   pNew->zPath = zFilename;
   pNew->ctrlFlags = (u8)ctrlFlags;
+  pNew->mmapLimit = SQLITE_DEFAULT_MMAP_LIMIT;
   if( sqlite3_uri_boolean(((ctrlFlags & UNIXFILE_URI) ? zFilename : 0),
                            "psow", SQLITE_POWERSAFE_OVERWRITE) ){
     pNew->ctrlFlags |= UNIXFILE_PSOW;
index b7534deb09fd7782f4a9188a11da5b1c81f4abeb..4cce8442377e7b48bf75ba4fb00e6f155d12fade 100644 (file)
@@ -657,8 +657,8 @@ struct Pager {
   char dbFileVers[16];        /* Changes whenever database file changes */
 
   u8 bUseFetch;               /* True to use xFetch() */
-  int nMapCfgLimit;           /* Configured limit value */
   int nMmapOut;               /* Number of mmap pages currently outstanding */
+  sqlite3_int64 mxMmap;       /* Desired maximum mmap size */
   PgHdr *pFree;               /* List of free mmap page headers (pDirty) */
   /*
   ** End of the routinely-changing class members
@@ -3354,23 +3354,15 @@ void sqlite3PagerSetCachesize(Pager *pPager, int mxPage){
 }
 
 /*
-** Invoke SQLITE_FCNTL_MMAP_SIZE based on the current value of nMapCfgLimit.
+** Invoke SQLITE_FCNTL_MMAP_LIMIT based on the current value of mxMmap.
 */
 static void pagerFixMaplimit(Pager *pPager){
   sqlite3_file *fd = pPager->fd;
   if( isOpen(fd) ){
-    pPager->bUseFetch = (fd->pMethods->iVersion>=3) && pPager->nMapCfgLimit!=0;
+    pPager->bUseFetch = (fd->pMethods->iVersion>=3) && pPager->mxMmap>0;
     if( pPager->bUseFetch ){
-      void *p;
-      i64 nMapLimit;
-      if( pPager->nMapCfgLimit<0 ){
-        nMapLimit = (i64)pPager->nMapCfgLimit * -1024;
-      }else{
-        nMapLimit = (i64)pPager->nMapCfgLimit * pPager->pageSize;
-      }
-
-      p = (void *)&nMapLimit;
-      sqlite3OsFileControlHint(pPager->fd, SQLITE_FCNTL_MMAP_SIZE, p);
+      sqlite3OsFileControlHint(pPager->fd, SQLITE_FCNTL_MMAP_LIMIT,
+                               (void*)&pPager->mxMmap);
     }
   }
 }
@@ -3378,8 +3370,8 @@ static void pagerFixMaplimit(Pager *pPager){
 /*
 ** Change the maximum size of any memory mapping made of the database file.
 */
-void sqlite3PagerSetMmapsize(Pager *pPager, int nMap){
-  pPager->nMapCfgLimit = nMap;
+void sqlite3PagerSetMmapLimit(Pager *pPager, sqlite3_int64 mxMmap){
+  pPager->mxMmap = mxMmap;
   pagerFixMaplimit(pPager);
 }
 
index 81ab30c1158aea8e6077b86f3b7d6627a22c33b8..6f659136e276079da43a2e39e1b68637ecadcf68 100644 (file)
@@ -108,7 +108,7 @@ void sqlite3PagerSetBusyhandler(Pager*, int(*)(void *), void *);
 int sqlite3PagerSetPagesize(Pager*, u32*, int);
 int sqlite3PagerMaxPageCount(Pager*, int);
 void sqlite3PagerSetCachesize(Pager*, int);
-void sqlite3PagerSetMmapsize(Pager *, int);
+void sqlite3PagerSetMmapLimit(Pager *, sqlite3_int64);
 void sqlite3PagerShrink(Pager*);
 void sqlite3PagerSetSafetyLevel(Pager*,int,int,int);
 int sqlite3PagerLockingMode(Pager *, int);
index 9b31797d3fd42505ca08ecfa38a4f405b4dae1be..cd1cfbe2131846b30a91bb6ac1c4e17e0743a24f 100644 (file)
@@ -745,26 +745,23 @@ void sqlite3Pragma(
   }else
 
   /*
-  **  PRAGMA [database.]mmap_size
-  **  PRAGMA [database.]mmap_size=N
+  **  PRAGMA [database.]mmap_limit(N)
   **
-  ** Used to set or query the mapping size limit. The mapping size limit is
+  ** Used to set mapping size limit. The mapping size limit is
   ** used to limit the aggregate size of all memory mapped regions of the
   ** database file. If this parameter is set to zero, then memory mapping
-  ** is not used at all. If it is set to a positive value, then it is
-  ** interpreted as a maximum size in pages. If set to less than zero, then
-  ** the absolute value is interpreted as a size limit in KB.
+  ** is not used at all. The parameter N is measured in bytes.
   **
-  ** The default value is zero (do not use memory mapped IO).
+  ** This value is advisory.  The underlying VFS is free to memory map
+  ** as little or as much as it wants.  Except, if N is set to 0 then the
+  ** upper layers will never invoke the xFetch interfaces to the VFS.
   */
-  if( sqlite3StrICmp(zLeft,"mmap_size")==0 ){
+  if( sqlite3StrICmp(zLeft,"mmap_limit")==0 ){
     assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
-    if( !zRight ){
-      returnSingleInt(pParse, "mmap_size", pDb->pSchema->mmap_size);
-    }else{
-      int size = sqlite3Atoi(zRight);
-      pDb->pSchema->mmap_size = size;
-      sqlite3BtreeSetMmapSize(pDb->pBt, pDb->pSchema->mmap_size);
+    if( zRight ){
+      sqlite3_int64 size;
+      sqlite3Atoi64(zRight, &size, 1000, SQLITE_UTF8);
+      sqlite3BtreeSetMmapLimit(pDb->pBt, size);
     }
   }else
 
index 72f8d329397d1728db4b23fcb7315deee140ac92..acb49bf5f9dc14adca8e4803c6c71c006d5a3a83 100644 (file)
@@ -886,9 +886,9 @@ struct sqlite3_io_methods {
 ** written into memory obtained from [sqlite3_malloc()].  The caller should
 ** invoke [sqlite3_free()] on the result to avoid a memory leak.
 **
-** <li>[[SQLITE_FCNTL_MMAP_SIZE]]
-** The argument is assumed to point to a value of type sqlite3_int64. An
-** advisory maximum amount of this file to memory map in bytes.
+** <li>[[SQLITE_FCNTL_MMAP_LIMIT]]
+** The argument is assumed to pointer to a value of type sqlite3_int64 that
+** is an advisory maximum number of bytes in the file to memory map.
 **
 ** </ul>
 */
@@ -908,7 +908,7 @@ struct sqlite3_io_methods {
 #define SQLITE_FCNTL_PRAGMA                 14
 #define SQLITE_FCNTL_BUSYHANDLER            15
 #define SQLITE_FCNTL_TEMPFILENAME           16
-#define SQLITE_FCNTL_MMAP_SIZE              18
+#define SQLITE_FCNTL_MMAP_LIMIT             18
 
 /*
 ** CAPI3REF: Mutex Handle
index 59483bc87b82ddaf941839678a42c68ef5cbaac2..129c4c5ea5417e68df838cd9d88ff05c675e4555 100644 (file)
@@ -746,7 +746,6 @@ struct Schema {
   u8 enc;              /* Text encoding used by this database */
   u16 flags;           /* Flags associated with this schema */
   int cache_size;      /* Number of pages to use in the cache */
-  int mmap_size;       /* Number of pages to memory map */
 };
 
 /*
index c7aee53cebca94da51e71a822ea5a6deb90385df..2013139456ce98c792e330b530a40f8c190b406f 100644 (file)
 #ifndef SQLITE_MAX_TRIGGER_DEPTH
 # define SQLITE_MAX_TRIGGER_DEPTH 1000
 #endif
+
+/*
+** Default maximum size of memory used by xFetch in the VFS.
+*/
+#ifndef SQLITE_DEFAULT_MMAP_LIMIT
+# define SQLITE_DEFAULT_MMAP_LIMIT (256*1024*1024)
+#endif
index 2541a1a82312ed4035e1c78af7f475cf06ebab1b..c2d9164fa28647b01f7d845ed773d67ceeec27a5 100644 (file)
@@ -40,7 +40,7 @@ proc db_write {db {reset 0}} {
 do_test 1.1 {
   db close
   sqlite3 db test.db
-  execsql { PRAGMA mmap_size = 0 }
+  execsql { PRAGMA mmap_limit = 0 }
   expr {[file size test.db] / 1024}
 } 6
 
index 4277e5c4c1a29452843ef250dc245b039e4bf059..fa564de0cfd357386a2396a8f1ad116a1d5d4fc2 100644 (file)
@@ -123,7 +123,7 @@ foreach AutoVacuumMode [list 0 1] {
   forcedelete test.db test.db-journal
 
   sqlite3 db test.db
-  execsql "PRAGMA mmap_size = 0"
+  execsql "PRAGMA mmap_limit = 0"
   execsql "PRAGMA auto_vacuum = $AutoVacuumMode"
 
   do_test incrblob-2.$AutoVacuumMode.1 {
@@ -150,7 +150,7 @@ foreach AutoVacuumMode [list 0 1] {
     # Open and close the db to make sure the page cache is empty.
     db close
     sqlite3 db test.db
-    execsql "PRAGMA mmap_size = 0"
+    execsql "PRAGMA mmap_limit = 0"
   
     # Read the last 20 bytes of the blob via a blob handle.
     set ::blob [db incrblob blobs v 1]
@@ -173,7 +173,7 @@ foreach AutoVacuumMode [list 0 1] {
     # Open and close the db to make sure the page cache is empty.
     db close
     sqlite3 db test.db
-    execsql "PRAGMA mmap_size = 0"
+    execsql "PRAGMA mmap_limit = 0"
   
     # Write the second-to-last 20 bytes of the blob via a blob handle.
     #
@@ -203,7 +203,7 @@ foreach AutoVacuumMode [list 0 1] {
     # Open and close the db to make sure the page cache is empty.
     db close
     sqlite3 db test.db
-    execsql { PRAGMA mmap_size = 0 }
+    execsql { PRAGMA mmap_limit = 0 }
 
     execsql { SELECT i FROM blobs } 
   } {45}
index 41714e29d8a21a034bb352d3f29f8fd968da5656..d97ada7e57b17a80087f39132111ca467c1e5ea8 100644 (file)
@@ -23,16 +23,16 @@ proc nRead {db} {
   return $stats(read)
 }
 
-foreach {t mmap_size nRead c2init} {
-  1.1 { PRAGMA mmap_size = -65536 }   4 {}
-  1.2 { PRAGMA mmap_size = -50    } 156 {}
-  1.3 { PRAGMA mmap_size = 0      } 344 {}
-  1.4 { PRAGMA mmap_size = -65536 }   4 {PRAGMA mmap_size = -65536}
-  1.5 { PRAGMA mmap_size = -50    } 156 {PRAGMA mmap_size = -65536}
-  1.6 { PRAGMA mmap_size = 0      } 344 {PRAGMA mmap_size = -65536}
+foreach {t mmap_limit nRead c2init} {
+  1.1 { PRAGMA mmap_limit = 70000000 }   4 {}
+  1.2 { PRAGMA mmap_limit =    51200 } 156 {}
+  1.3 { PRAGMA mmap_limit =        0 } 344 {}
+  1.4 { PRAGMA mmap_limit = 70000000 }   4 {PRAGMA mmap_limit = 70000000 }
+  1.5 { PRAGMA mmap_limit =    51200 } 156 {PRAGMA mmap_limit = 70000000 }
+  1.6 { PRAGMA mmap_limit =        0 } 344 {PRAGMA mmap_limit = 70000000 }
 } {
   do_multiclient_test tn {
-    sql1 $mmap_size
+    sql1 $mmap_limit
     sql2 $c2init
 
     code2 {
@@ -78,7 +78,7 @@ foreach {t mmap_size nRead c2init} {
     } {64 ok 149}
 
     # Check that the number of pages read by connection 1 indicates that the
-    # "PRAGMA mmap_size" command worked.
+    # "PRAGMA mmap_limit" command worked.
     do_test $t.$tn.5 { nRead db } $nRead
   }
 }
@@ -95,7 +95,7 @@ db func rblob rblob
 
 do_execsql_test 2.1 {
   PRAGMA auto_vacuum = 1;
-  PRAGMA mmap_size = -65536;
+  PRAGMA mmap_limit = 70000000;
   PRAGMA journal_mode = wal;
   CREATE TABLE t1(a, b, UNIQUE(a, b));
   INSERT INTO t1 VALUES(rblob(500), rblob(500));
@@ -130,4 +130,3 @@ do_execsql_test 2.4 {
 } {0 24 24}
 
 finish_test
-
index 9ff3a801c267d2ed3c858af3e5343f83e5f8b6ef..2e529fa880dd915c1f85d58b9a9c02656b571bdc 100644 (file)
@@ -138,10 +138,10 @@ test_suite "veryquick" -prefix "" -description {
   test_set $allquicktests -exclude *malloc* *ioerr* *fault*
 ]
 
-test_suite "mmap" -prefix "mm-" -description {
-  Similar to veryquick. Except with memory mapping enabled.
+test_suite "no-mmap" -prefix "nomm-" -description {
+  Similar to veryquick. Except with memory mapping disabled.
 } -presql {
-  pragma mmap_size = -65536;
+  pragma mmap_size = 0;
 } -files [
   test_set $allquicktests -exclude *malloc* *ioerr* *fault* -include malloc.test
 ]
index df5abedde380b630624030bad752345d39237e89..915f1653541ec8628c6927ef7d75e1a6e595edbc 100644 (file)
@@ -65,7 +65,6 @@ proc number_name {n} {
 #
 do_test speed1p-1.0 {
   execsql {
-    PRAGMA mmap_size=1000000;
     PRAGMA page_size=1024;
     PRAGMA cache_size=500;
     PRAGMA locking_mode=EXCLUSIVE;
index bf7df5df5ff5468a47e812c70c06f4fa4480a7f6..4ecaa1fabcf090d147e3052d0a98511b30215c1c 100644 (file)
@@ -262,7 +262,7 @@ do_faultsim_test 4 -faults vfsfault-* -prep {
   faultsim_restore_and_reopen
   file_control_chunksize_test db main 8192
   execsql { 
-    PRAGMA mmap_size = 1000000;
+    PRAGMA mmap_limit = 1000000;
   }
 } -body {
   test_syscall errno mmap     EACCES
@@ -275,4 +275,3 @@ do_faultsim_test 4 -faults vfsfault-* -prep {
 }
 
 finish_test
-
index d8bf541a4bbd4ddc5d6926e4eb2d89520c677f05..ebd1dbfc3179f898bf6ea52bad24f9b61489d22f 100644 (file)
@@ -241,8 +241,8 @@ foreach {testprefix do_wal_checkpoint} {
     # [sql2] commmand above. So normally, the db is 1 page in size here.
     # However, in mmap() mode, the db is pre-allocated to 2 pages at the
     # start of the checkpoint, even though page 2 cannot be written.
-    set nDb 1
-    if {[permutation]=="mmap"} {set nDb 2}
+    set nDb 2
+    if {[permutation]=="no-mmap"} {set nDb 1}
     do_test 2.3.$tn.8 { file_page_counts } [list $nDb 4 2 4]
   }
 
@@ -351,4 +351,3 @@ foreach {testprefix do_wal_checkpoint} {
 
 
 finish_test
-