1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-14 00:22:38 +03:00

Add the SQLITE_CONFIG_MMAP_LIMIT configuration option for overriding the

SQLITE_DEFAULT_MMAP_LIMIT compile-time setting.  Enhance "PRAGMA mmap_limit"
so that without a specific database name, it sets the limit on all database
files and changes the default for any future databases that might be added
using ATTACH.

FossilOrigin-Name: 78141d0a16dd1d56b575fccd149de7fa789cb06c
This commit is contained in:
drh
2013-04-01 22:38:06 +00:00
parent a539c8a464
commit a1f42c7c32
10 changed files with 53 additions and 17 deletions

View File

@@ -750,7 +750,9 @@ void sqlite3Pragma(
** 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. The parameter N is measured in bytes.
** is not used at all. If N is negative, then the default memory map
** limit determined by sqlite3_config(SQLITE_CONFIG_MMAP_LIMIT) is set.
** The parameter N is measured in bytes.
**
** 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
@@ -760,8 +762,15 @@ void sqlite3Pragma(
assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
if( zRight ){
sqlite3_int64 size;
int ii;
sqlite3Atoi64(zRight, &size, 1000, SQLITE_UTF8);
sqlite3BtreeSetMmapLimit(pDb->pBt, size);
if( size<0 ) size = sqlite3GlobalConfig.mxMmap;
if( pId2->n==0 ) db->mxMmap = size;
for(ii=db->nDb-1; ii>=0; ii--){
if( db->aDb[ii].pBt && (ii==iDb || pId2->n==0) ){
sqlite3BtreeSetMmapLimit(db->aDb[ii].pBt, size);
}
}
}
}else