On 16 Nov 2013, at 11:37pm, Joshua Grauman <jnf...@grauman.com> wrote:
> Or conversely, that if sqlite has the file open to write, my program will > read a cached version (if reading and writing happen at the same time, I'm > fine with the reader getting a slightly stale version). But I'm not > completely clear on how Linux file locking works... So do I need to add a > mutex to my program to make sure that a reader doesn't get a corrupt database > file? Good questions, checking a bad assumption. There is no such thing as a 'cached version' of a database file. Unix doesn't do things like that. Imagine you had a database file that was 20GB long. How long do you think it would take to make a cached version, and where do you think it would put it ?. So if you're reading a database file without using locking then you're running the risk of reading some of it before a change and some of it after the change. So yes, you need some form of mutex. Or to use the SQLite backup API to read the file. Or to use the normal SQLite API to open the file read/only and read all the data. Simon. _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users