On Thu, Nov 7, 2013 at 4:31 PM, L. Wood <lwoo...@live.com> wrote:
> Users could rename/move a database file while my (Mac OS X) program has made 
> an SQLite connection to the file. I want to handle this properly.

One thing you have to be particularly careful about is the extra files
sqlite creates next to the database file, such as the rollback journal
files.  The page http://sqlite.org/tempfiles.html documents how sqlite
currently uses these.  In particular, if sqlite finds the database
file but does not file the associated journal file, your database can
go corrupted.  I don't know how you could assure that this does not
happen.

Instead of trying to handle errors from the frontend of sqlite, you
might get a more robust solution if you wrote a custom VFS backend for
sqlite, possibly by modifying the existing uniq VSF backend.  The VFS
is documented on http://sqlite.org/vfs.html .

Sqlite performs all operating system dependent functions through the
replacable VFS backend.  These operations include opening a file,
reading, writing, file locking.  This way if, for example, if you
detect that a user have moved the database file and sqlite wants to
open the corresponding rollback journal file, you can make sure that
it opens the correct rollback journal.

Besides ensuring that there the extra files are found correctly, you
will also have to make sure that file locking works correctly accross
moves.  All this gets quite complicated (maybe even impossible),
especially if multiple programs want to open the same sqlite database
concurrently.

Ambrus
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to