So, if I am already using an old version before 3.11 and enable the mmap, the 
data may lost after os crash. It’s that right?


原始邮件
发件人:Richard [email protected]
收件人:SQLite mailing [email protected]
发送时间:2016年11月3日(周四) 21:21
主题:Re: [sqlite] Is msync necessary for SQLite?


On 11/3/16, sanhua.zh [email protected] 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 
[email protected]  收件人:SQLite mailing [email protected] 
 发送时间:2016年11月3日(周四) 17:49  主题:Re: [sqlite] Is msync necessary for SQLite?    
On 11/3/16, sanhua.zh [email protected] 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 
[email protected] _______________________________________________  sqlite-users 
mailing list [email protected]  
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users  
_______________________________________________  sqlite-users mailing list  
[email protected]  
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users  -- D. 
Richard Hipp [email protected] _______________________________________________ 
sqlite-users mailing list [email protected] 
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
[email protected]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to