aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ctime.c3
-rw-r--r--src/os_unix.c4
-rw-r--r--src/os_win.c4
-rw-r--r--src/pager.c5
-rw-r--r--src/pragma.c14
-rw-r--r--src/sqlite.h.in4
-rw-r--r--src/sqliteLimit.h10
7 files changed, 27 insertions, 17 deletions
diff --git a/src/ctime.c b/src/ctime.c
index c42454ca7..ee6d4cbe2 100644
--- a/src/ctime.c
+++ b/src/ctime.c
@@ -57,6 +57,9 @@ static const char * const azCompileOpt[] = {
#ifdef SQLITE_DEFAULT_LOCKING_MODE
"DEFAULT_LOCKING_MODE=" CTIMEOPT_VAL(SQLITE_DEFAULT_LOCKING_MODE),
#endif
+#ifdef SQLITE_DEFAULT_MMAP_LIMIT
+ "DEFAULT_MMAP_LIMIT=" CTIMEOPT_VAL(SQLITE_DEFAULT_MMAP_LIMIT),
+#endif
#ifdef SQLITE_DISABLE_DIRSYNC
"DISABLE_DIRSYNC",
#endif
diff --git a/src/os_unix.c b/src/os_unix.c
index 39a31cb18..75f923601 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -3710,7 +3710,9 @@ static int unixFileControl(sqlite3_file *id, int op, void *pArg){
return SQLITE_OK;
}
case SQLITE_FCNTL_MMAP_LIMIT: {
- pFile->mmapLimit = *(i64*)pArg;
+ i64 newLimit = *(i64*)pArg;
+ *(i64*)pArg = pFile->mmapLimit;
+ if( newLimit>=0 ) pFile->mmapLimit = newLimit;
return SQLITE_OK;
}
#ifdef SQLITE_DEBUG
diff --git a/src/os_win.c b/src/os_win.c
index 74aede570..dc69b47ae 100644
--- a/src/os_win.c
+++ b/src/os_win.c
@@ -2837,7 +2837,9 @@ static int winFileControl(sqlite3_file *id, int op, void *pArg){
return SQLITE_OK;
}
case SQLITE_FCNTL_MMAP_LIMIT: {
- pFile->mmapLimit = *(i64*)pArg;
+ i64 newLimit = *(i64*)pArg;
+ *(i64*) = pFile->mmapLimit;
+ if( newLimit>=0 ) pFile->mmapLimit = newLimit;
return SQLITE_OK;
}
}
diff --git a/src/pager.c b/src/pager.c
index f626a21d8..ae2f10069 100644
--- a/src/pager.c
+++ b/src/pager.c
@@ -3358,9 +3358,10 @@ void sqlite3PagerSetCachesize(Pager *pPager, int mxPage){
static void pagerFixMaplimit(Pager *pPager){
sqlite3_file *fd = pPager->fd;
if( isOpen(fd) ){
+ sqlite3_int64 mx;
pPager->bUseFetch = (fd->pMethods->iVersion>=3) && pPager->mxMmap>0;
- sqlite3OsFileControlHint(pPager->fd, SQLITE_FCNTL_MMAP_LIMIT,
- (void*)&pPager->mxMmap);
+ mx = pPager->mxMmap;
+ sqlite3OsFileControlHint(pPager->fd, SQLITE_FCNTL_MMAP_LIMIT, &mx);
}
}
diff --git a/src/pragma.c b/src/pragma.c
index 7a515cba2..3527c0974 100644
--- a/src/pragma.c
+++ b/src/pragma.c
@@ -759,19 +759,23 @@ void sqlite3Pragma(
** upper layers will never invoke the xFetch interfaces to the VFS.
*/
if( sqlite3StrICmp(zLeft,"mmap_limit")==0 ){
+ sqlite3_int64 mx;
assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
if( zRight ){
- sqlite3_int64 size;
int ii;
- sqlite3Atoi64(zRight, &size, 1000, SQLITE_UTF8);
- if( size<0 ) size = sqlite3GlobalConfig.mxMmap;
- if( pId2->n==0 ) db->mxMmap = size;
+ sqlite3Atoi64(zRight, &mx, 1000, SQLITE_UTF8);
+ if( mx<0 ) mx = sqlite3GlobalConfig.mxMmap;
+ if( pId2->n==0 ) db->mxMmap = mx;
for(ii=db->nDb-1; ii>=0; ii--){
if( db->aDb[ii].pBt && (ii==iDb || pId2->n==0) ){
- sqlite3BtreeSetMmapLimit(db->aDb[ii].pBt, size);
+ sqlite3BtreeSetMmapLimit(db->aDb[ii].pBt, mx);
}
}
}
+ mx = -1;
+ if( sqlite3_file_control(db,zDb,SQLITE_FCNTL_MMAP_LIMIT,&mx)==SQLITE_OK ){
+ returnSingleInt(pParse, "mmap_limit", mx);
+ }
}else
/*
diff --git a/src/sqlite.h.in b/src/sqlite.h.in
index de1316606..a4fb1a8a9 100644
--- a/src/sqlite.h.in
+++ b/src/sqlite.h.in
@@ -888,7 +888,9 @@ struct sqlite3_io_methods {
**
** <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.
+** is an advisory maximum number of bytes in the file to memory map. The
+** pointer is overwritten with the old value. The limit is not changed if
+** the original value pointed to is negative.
**
** </ul>
*/
diff --git a/src/sqliteLimit.h b/src/sqliteLimit.h
index 826d19dd9..2b02cc566 100644
--- a/src/sqliteLimit.h
+++ b/src/sqliteLimit.h
@@ -219,13 +219,9 @@
#ifndef SQLITE_DEFAULT_MMAP_LIMIT
# if defined(__linux__) \
|| defined(_WIN32) \
- || (defined(__APPLE__) && defined(__MACH__) && !defined(TARGET_OS_IPHONE)) \
- || defined(__sun) \
- || defined(__DragonFly__) \
- || defined(__FreeBSD__) \
- || defined(__NetBSD__) \
- || defined(__OpenBSD__)
-# define SQLITE_DEFAULT_MMAP_LIMIT (256*1024*1024)
+ || (defined(__APPLE__) && defined(__MACH__)) \
+ || defined(__sun)
+# define SQLITE_DEFAULT_MMAP_LIMIT 268435456 /* = 256*1024*1024 */
# else
# define SQLITE_DEFAULT_MMAP_LIMIT 0
# endif