Index: src/os_unix.c ================================================================== --- src/os_unix.c +++ src/os_unix.c @@ -3468,10 +3468,18 @@ ** source. */ if( pFile->inNormalWrite && nByte==0 ){ pFile->transCntrChng = 1; } + + /* If the file was just truncated to a size smaller than the currently + ** mapped region, reduce the effective mapping size as well. SQLite will + ** use read() and write() to access data beyond this point from now on. + */ + if( nBytemmapSize ){ + pFile->mmapSize = nByte; + } #endif return SQLITE_OK; } } @@ -4459,11 +4467,11 @@ void *pNew = 0; /* New mapping */ i64 nNewRnd; /* nNew rounded up */ i64 nOldRnd; /* nOld rounded up */ assert( iOff==0 ); - assert( p->mmapSize==nOld ); + /* assert( p->mmapSize==nOld ); */ assert( p->pMapRegion==0 || p->pMapRegion==(*ppMap) ); /* If the SQLITE_MREMAP_EXTEND flag is set, then the size of the requested ** mapping (nNew bytes) may be greater than the size of the database file. ** If this is the case, extend the file on disk using ftruncate(). */