On 11/3/16, sanhua.zh <sanhua...@foxmail.com> wrote: > Here is a part of code in [unixWrite]. (os_unix.h) > Is not it written by mmap ?
You are looking at older code that is not longer used. Look at latest sources and you will see that the code you quote below is enclosed within #if defined(SQLITE_MMAP_READWRITE) ... #endif So writing to mmapped memory only happens if you compile with the (undocumented, unsupported, and untested) -DSQLITE_MMAP_READWRITE option. > > > #if SQLITE_MAX_MMAP_SIZE0 > /* Deal with as much of this write request as possible by transfering > ** data from the memory mapping using memcpy(). */ > if( offsetpFile-mmapSize ){ > if( offset+amt = pFile-mmapSize ){ > int size = -1; > struct stat buf; /* Used to hold return values of fstat() */ > if( !osFstat(pFile-h, buf) ){ > size = (int)buf.st_size; > } > memcpy(((u8 *)(pFile-pMapRegion))[offset], pBuf, amt); > return SQLITE_OK; > }else{ > int nCopy = (int)(pFile-mmapSize - offset); > memcpy(((u8 *)(pFile-pMapRegion))[offset], pBuf, nCopy); > pBuf = ((u8 *)pBuf)[nCopy]; > amt -= nCopy; > offset += nCopy; > } > } > #endif > > > > > 原始邮件 > 发件人:Richard hipp...@sqlite.org > 收件人:SQLite mailing listsqlite-us...@mailinglists.sqlite.org > 发送时间:2016年11月3日(周四) 17:49 > 主题:Re: [sqlite] Is msync necessary for SQLite? > > > On 11/3/16, sanhua.zh sanhua...@foxmail.com wrote: I run in iOS. The mmap > is enable in recent version. So, once a mmap enable, data may lost after os > crash unless msync. But I can’t find anywhere in the source of SQLite call > the msync. Is it a bug? No. Mmap() is only used for reading, not writing. > All changes are implemented by calling write() and fsync(). -- D. Richard > Hipp d...@sqlite.org _______________________________________________ > sqlite-users mailing list sqlite-users@mailinglists.sqlite.org > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users > _______________________________________________ > sqlite-users mailing list > sqlite-users@mailinglists.sqlite.org > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users > -- D. Richard Hipp d...@sqlite.org _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users