I'm aware that a database in WAL mode can't be opened read-only if its 
directory isn't writeable[1]. However, I'm unexpectedly getting errors opening 
a database when the directory _is_ writeable, but the database is opened 
read-only. Specifically:

* The database file is in WAL mode.
* The -wal and -shm files do not exist (i.e. the database was previously closed 
cleanly.)
* The directory containing the database is writeable (i.e. the process is 
allowed to create files in it.)
* The database is opened with sqlite3_open_v2, using the SQLITE_OPEN_READONLY 
flag.

In this situation, any SQLite call that actually accesses the database will 
fail with SQLITE_CANTOPEN.

It seems as though SQLite decides that because the handle is read-only, it's 
not allowed to create the -shm file. There's some logic to this, but I can't 
find any mention of it in the documentation.

(I'm using SQLite 3.16 on macOS 10.12.4.)

—Jens

[1]: https://www.sqlite.org/wal.html#readonly
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to