SQLite Forum

Hooks invoked when modifications done from another connection?
Login
The [C API][5] has various *hook* APIs, for [commit and rollback][1], [update][2], [pre-update][3], and finally [wal commit][4].

The doc is not 100% clear however, on whether those hooks are called back only when it's the  
connection the hook was registered with, that made the change; or whether they will also be called  
back when those changes originate in a different connection (in the same process, or another).

The way I read it, only the last (wal) hook may be cross-connection, because it uses the phrase  
*invoked each time data is committed to a database in wal mode*, emphasis on **database**, not  
**connection**; while for other hooks, *connection* is used.

Is my reading of the doc correct?

What I actually need is an accurate timestamp to know when any DB managed by my server was  
last modified. With the twist that several instances of the server may be running, *on* the same DBs.  
And I'm thus wondering whether to tackle this via SQLite hooks, or using a more ad-hoc approach  
in my own code / connections only.

An SQLite solution would work with any app (connection) doing changes,  
including the official shell tool, while my ad-hoc solution would be tied to my code.

Thanks, --DD

PS: I'm still using *Journal mode* BTW, but was planning on switching to WAL.

[1]: https://www.sqlite.org/c3ref/commit_hook.html
[2]: https://www.sqlite.org/c3ref/update_hook.html
[3]: https://www.sqlite.org/c3ref/preupdate_count.html
[4]: https://www.sqlite.org/c3ref/wal_hook.html
[5]: https://www.sqlite.org/c3ref/funclist.html