-C Changes\sto\swal.c\sso\sthat\sSQLite\scan\sread\seven\sif\sthe\sWAL\sfile\sis\sopened\sread-only,\sprovided\sthe\swal-index\s(shm\sfile)\sis\sopened\sread/write.
-D 2010-07-15T18:20:54
+-----BEGIN PGP SIGNED MESSAGE-----
+Hash: SHA1
+
+C Optionally\ssupport\sshared-memory\sin\s/dev/shm\sor\sother\stmpfs\sdirectory\nusing\san\sunsupported\scompile-time\soption.
+D 2010-07-15T18:32:41
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in ec08dc838fd8110fe24c92e5130bcd91cbb1ff2e
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
F src/os.h 9dbed8c2b9c1f2f2ebabc09e49829d4777c26bf9
F src/os_common.h a8f95b81eca8a1ab8593d23e94f8a35f35d4078f
F src/os_os2.c 665876d5eec7585226b0a1cf5e18098de2b2da19
-F src/os_unix.c 73cce1696c0c9e27a6277946b016e4f2077e365e
+F src/os_unix.c d27404c02d3947737f8650ca4586afa7c1bec32a
F src/os_win.c 61734aad7f50b28f3c76eb4b19b63472f6d825d9
F src/pager.c 78ca1e1f3315c8227431c403c04d791dccf242fb
F src/pager.h 879fdde5a102d2f21a3135d6f647530b21c2796c
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
-P 75f5354876c4300a8e53fe551dc837dd383d1e38
-R 5fdef461b56aef5e86f35d4620ab20d6
-U dan
-Z 679f6331e7be3f40e18fcb4456a4e594
+P 932d19da73c9673cdd4cc01289b17761c23d23cb
+R fdcb07e29996e92060dad2eee68d833c
+U drh
+Z 26a418d4204c9feaabc8860a4e746939
+-----BEGIN PGP SIGNATURE-----
+Version: GnuPG v1.4.6 (GNU/Linux)
+
+iD8DBQFMP1RMoxKgR168RlERAhh6AJ4umgQHctPd2gEiJRrgEectm89sNQCZAbaB
+OhN8MrDeGSxCC/JtQI6sM68=
+=f3eu
+-----END PGP SIGNATURE-----
** as the open database file and has the same name as the open database
** file with the "-shm" suffix added. For example, if the database file
** is "/home/user1/config.db" then the file that is created and mmapped
-** for shared memory will be called "/home/user1/config.db-shm". We
-** experimented with using files in /dev/tmp or an some other tmpfs mount.
-** But if a file in a different directory from the database file is used,
-** then differing access permissions or a chroot() might cause two different
-** processes on the same database to end up using different files for
-** shared memory - meaning that their memory would not really be shared -
-** resulting in database corruption.
+** for shared memory will be called "/home/user1/config.db-shm".
+**
+** Another approach to is to use files in /dev/shm or /dev/tmp or an
+** some other tmpfs mount. But if a file in a different directory
+** from the database file is used, then differing access permissions
+** or a chroot() might cause two different processes on the same
+** database to end up using different files for shared memory -
+** meaning that their memory would not really be shared - resulting
+** in database corruption. Nevertheless, this tmpfs file usage
+** can be enabled at compile-time using -DSQLITE_SHM_DIRECTORY="/dev/shm"
+** or the equivalent. The use of the SQLITE_SHM_DIRECTORY compile-time
+** option results in an incompatible build of SQLite; builds of SQLite
+** that with differing SQLITE_SHM_DIRECTORY settings attempt to use the
+** same database file at the same time, database corruption will likely
+** result. The SQLITE_SHM_DIRECTORY compile-time option is considered
+** "unsupported" and may go away in a future SQLite release.
**
** When opening a new shared-memory file, if no other instances of that
** file are currently open, in this process or in other processes, then
goto shm_open_err;
}
+#ifdef SQLITE_SHM_DIRECTORY
+ nShmFilename = sizeof(SQLITE_SHM_DIRECTORY) + 30;
+#else
nShmFilename = 5 + (int)strlen(pDbFd->zPath);
+#endif
pShmNode = sqlite3_malloc( sizeof(*pShmNode) + nShmFilename );
if( pShmNode==0 ){
rc = SQLITE_NOMEM;
}
memset(pShmNode, 0, sizeof(*pShmNode));
zShmFilename = pShmNode->zFilename = (char*)&pShmNode[1];
+#ifdef SQLITE_SHM_DIRECTORY
+ sqlite3_snprintf(nShmFilename, zShmFilename,
+ SQLITE_SHM_DIRECTORY "/sqlite-shm-%x-%x",
+ (u32)sStat.st_ino, (u32)sStat.st_dev);
+#else
sqlite3_snprintf(nShmFilename, zShmFilename, "%s-shm", pDbFd->zPath);
+#endif
pShmNode->h = -1;
pDbFd->pInode->pShmNode = pShmNode;
pShmNode->pInode = pDbFd->pInode;
**
** If the file being opened is a temporary file, it is always created with
** the octal permissions 0600 (read/writable by owner only). If the file
-** is a database or master journal file, it is created with the permissions
-** mask SQLITE_DEFAULT_FILE_PERMISSIONS.
+** is a database, journal or master journal file, it is created with the
+** permissions mask SQLITE_DEFAULT_FILE_PERMISSIONS.
**
-** Finally, if the file being opened is a WAL or regular journal file, then
-** this function queries the file-system for the permissions on the
-** corresponding database file and sets *pMode to this value. Whenever
-** possible, WAL and journal files are created using the same permissions
-** as the associated database file.
+** Finally, if the file being opened is a WAL file, then this function
+** queries the file-system for the permissions on the corresponding database
+** file and sets *pMode to this value. Whenever possible, WAL files are
+** created using the same permissions as the associated database file.
*/
static int findCreateFileMode(
const char *zPath, /* Path of file (possibly) being created */
mode_t *pMode /* OUT: Permissions to open file with */
){
int rc = SQLITE_OK; /* Return Code */
- if( flags & (SQLITE_OPEN_WAL|SQLITE_OPEN_MAIN_JOURNAL) ){
+ if( flags & SQLITE_OPEN_WAL ){
char zDb[MAX_PATHNAME+1]; /* Database file path */
int nDb; /* Number of valid bytes in zDb */
struct stat sStat; /* Output of stat() on database file */
- nDb = sqlite3Strlen30(zPath) - ((flags & SQLITE_OPEN_WAL) ? 4 : 8);
+ nDb = sqlite3Strlen30(zPath) - 4;
memcpy(zDb, zPath, nDb);
zDb[nDb] = '\0';
if( 0==stat(zDb, &sStat) ){
rc = findCreateFileMode(zName, flags, &openMode);
if( rc!=SQLITE_OK ){
assert( !p->pUnused );
- assert( eType==SQLITE_OPEN_WAL || eType==SQLITE_OPEN_MAIN_JOURNAL );
return rc;
}
fd = open(zName, openFlags, openMode);