mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-15 11:41:13 +03:00
Cause the mmap_size PRAGMA to immediately change the mmap space if the
database connection is already active. In particular, reducing mmap_size will immediately free up process address space. FossilOrigin-Name: 761177927cb51e4f5e66061ca39cf37edbe8346b
This commit is contained in:
16
src/os_win.c
16
src/os_win.c
@@ -2816,6 +2816,9 @@ static void winModeBit(winFile *pFile, unsigned char mask, int *pArg){
|
||||
|
||||
/* Forward declaration */
|
||||
static int getTempname(int nBuf, char *zBuf);
|
||||
#if SQLITE_MAX_MMAP_SIZE>0
|
||||
static int winMapfile(winFile*, sqlite3_int64);
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Control and query of the open file handle.
|
||||
@@ -2899,13 +2902,20 @@ static int winFileControl(sqlite3_file *id, int op, void *pArg){
|
||||
#if SQLITE_MAX_MMAP_SIZE>0
|
||||
case SQLITE_FCNTL_MMAP_SIZE: {
|
||||
i64 newLimit = *(i64*)pArg;
|
||||
int rc = SQLITE_OK;
|
||||
if( newLimit>sqlite3GlobalConfig.mxMmap ){
|
||||
newLimit = sqlite3GlobalConfig.mxMmap;
|
||||
}
|
||||
*(i64*)pArg = pFile->mmapSizeMax;
|
||||
if( newLimit>=0 ) pFile->mmapSizeMax = newLimit;
|
||||
OSTRACE(("FCNTL file=%p, rc=SQLITE_OK\n", pFile->h));
|
||||
return SQLITE_OK;
|
||||
if( newLimit>=0 && newLimit!=pFile->mmapSizeMax && pFile->nFetchOut==0 ){
|
||||
pFile->mmapSizeMax = newLimit;
|
||||
if( pFile->mmapSize>0 ){
|
||||
(void)winUnmapfile(pFile);
|
||||
rc = winMapfile(pFile, -1);
|
||||
}
|
||||
}
|
||||
OSTRACE(("FCNTL file=%p, rc=%d\n", pFile->h, rc));
|
||||
return rc;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user