Re: notify all processes of database modification

Rowan Worth <[email protected]>
Newsgroups gmane.comp.db.sqlite.general
Message-ID <CAJtcO2T8C3jzJ27+yxmbbPCUf6k9PJQV5Cr2avsnm8KPfCOQ+g@mail.gmail.com>
On Sat, 8 Feb 2020 at 04:02, Jens Alfke <[email protected]> wrote:

> > On Feb 7, 2020, at 6:23 AM, Kees Nuyt <[email protected]> wrote:
> >
> > Anyway, SQLite doesn't have such a mechanism by itself.
> > Maybe inotify is useful to you :
> >
> > https://en.wikipedia.org/wiki/Inotify <
> https://en.wikipedia.org/wiki/Inotify>
> > http://man7.org/linux/man-pages/man7/inotify.7.html <
> http://man7.org/linux/man-pages/man7/inotify.7.html>
>
> Or on Apple platforms, FSEvents.
>
> On any platform, you'd need to monitor both the main database and the .wal
> file.
>
> And the notification would trigger soon after a transaction began making
> changes, although the changes wouldn't be visible to you until the commit,
> so you'd probably need to start polling until you see the changes, with
> some heuristic about timing out if nothing happens for a while (e.g. if the
> transaction is aborted.)
>

See also PRAGMA data_version when it comes to polling the DB, the return
value of which changes when another process modifies the DB. IIRC the
implementation of this depends on a value in the DB header page, so it may
be sufficient to only monitor the main DB file for changes.

https://www.sqlite.org/pragma.html#pragma_data_version
-Rowan
_______________________________________________
sqlite-users mailing list
[email protected]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.