aboutsummaryrefslogtreecommitdiff
path: root/src/os_unix.c
diff options
context:
space:
mode:
authordan <dan@noemail.net>2010-11-05 18:07:37 +0000
committerdan <dan@noemail.net>2010-11-05 18:07:37 +0000
commita0c989dde776d428f4696b9de161bda3ed30be3a (patch)
tree4a8a0cf56bdae187786b6593e1aeeec8dee0d4c2 /src/os_unix.c
parentb5830294dcede5619c53673d85f9fd49b5205d59 (diff)
downloadsqlite-a0c989dde776d428f4696b9de161bda3ed30be3a.tar.gz
sqlite-a0c989dde776d428f4696b9de161bda3ed30be3a.zip
Fix os_unix.c so that it works with the test_multiplex module.
FossilOrigin-Name: 72ba3e368bec34532ec7b5e856a4daa7e1c8cccb
Diffstat (limited to 'src/os_unix.c')
-rw-r--r--src/os_unix.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/os_unix.c b/src/os_unix.c
index 2b38fd6ca..9e93a9dcb 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -4431,9 +4431,24 @@ static int findCreateFileMode(
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);
+ /* zPath is a path to a WAL or journal file. The following block derives
+ ** the path to the associated database file from zPath. This block handles
+ ** the following naming conventions:
+ **
+ ** "<path to db>-journal"
+ ** "<path to db>-wal"
+ ** "<path to db>-journal-NNNN"
+ ** "<path to db>-wal-NNNN"
+ **
+ ** where NNNN is a 4 digit decimal number. The NNNN naming schemes are
+ ** used by the test_multiplex.c module.
+ */
+ nDb = sqlite3Strlen30(zPath) - 1;
+ while( nDb>0 && zPath[nDb]!='l' ) nDb--;
+ nDb -= ((flags & SQLITE_OPEN_WAL) ? 3 : 7);
memcpy(zDb, zPath, nDb);
zDb[nDb] = '\0';
+
if( 0==stat(zDb, &sStat) ){
*pMode = sStat.st_mode & 0777;
}else{