1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-10 01:02:56 +03:00

Refactoring the mmap interface. The controlling pragma is now "mmap_size"

instead of "mmap_limit".  Also change SQLITE_CONFIG_MMAP_LIMIT and
SQLITE_FCNTL_MMAP_LIMIT to SQLITE_CONFIG_MMAP_SIZE and
SQLITE_FCNTL_MMAP_SIZE, respecctively.  
The default mmap_size is now always 0, meaning that
memory mapped I/O is off by default.  There is a new compile-time option
SQLITE_MAX_MMAP_SIZE that determines a hard upper bound on the mmap_size.
Setting SQLITE_MAX_MMAP_SIZE to zero disables the memory-mapped I/O logic
and causes it to be omitted from the build.  An extra argument is added
to SQLITE_CONFIG_MMAP_SIZE that can optionally lower the SQLITE_MAX_MMAP_SIZE
at start-time. The SQLITE_MAX_MMAP_SIZE is zero for platforms where we 
know that it does not work, meaning that it cannot be turned on by mistake
on those platforms.

FossilOrigin-Name: ea1404a10abd7f68e1f8e0708c8a3199d1f79665
This commit is contained in:
drh
2013-04-15 17:03:42 +00:00
parent a1710cc2ea
commit 9b4c59fa1b
31 changed files with 245 additions and 213 deletions

View File

@@ -496,10 +496,16 @@ int sqlite3_config(int op, ...){
}
#endif
case SQLITE_CONFIG_MMAP_LIMIT: {
case SQLITE_CONFIG_MMAP_SIZE: {
sqlite3_int64 szMmap = va_arg(ap, sqlite3_int64);
sqlite3_int64 mxMmap = va_arg(ap, sqlite3_int64);
if( mxMmap<0 ) mxMmap = SQLITE_DEFAULT_MMAP_LIMIT;
if( mxMmap<0 || mxMmap>SQLITE_MAX_MMAP_SIZE ){
mxMmap = SQLITE_MAX_MMAP_SIZE;
}
sqlite3GlobalConfig.mxMmap = mxMmap;
if( szMmap<0 ) szMmap = SQLITE_DEFAULT_MMAP_SIZE;
if( szMmap>mxMmap) szMmap = mxMmap;
sqlite3GlobalConfig.szMmap = szMmap;
break;
}
@@ -2323,7 +2329,7 @@ static int openDatabase(
memcpy(db->aLimit, aHardLimit, sizeof(db->aLimit));
db->autoCommit = 1;
db->nextAutovac = -1;
db->mxMmap = sqlite3GlobalConfig.mxMmap;
db->szMmap = sqlite3GlobalConfig.szMmap;
db->nextPagesize = 0;
db->flags |= SQLITE_ShortColNames | SQLITE_AutoIndex | SQLITE_EnableTrigger
#if SQLITE_DEFAULT_FILE_FORMAT<4